# Can I create an if formula to round decimals with differents statements?

I'm having trouble trying to create the formula to round numbers with an if function. I need to round decimals between 5 different statements:

• If a number has decimals between 0.1 and 0.5 rounddown to 0.
• If a number has decimals between 0.6 and 0.29 round to 0.25.
• If a number has decimals between 0.30 and 0.55 round to 0.50.
• If a number has decimals between 0.56 and 0.80 round to 0.75.
• If a number has decimals between 0.76 and 0.99 round to 1.
• Hi and welcome to WebApps. Would you please clarify some aspects of your question: you say If a number has decimals, so do you mean that you're only dealing with values between 0 and 1, can this be any number; e.g. 4.23, 6.95, etc. Second, there is a problem in the sequence of decimals values (maybe just a typo). "0.1 and 0.5": "0.5" must be wrong because the next level = 0.29. "0.6 and 0.29": "0.6" must be wrong because it is greater than 0.29". "0.76 and 0.99": do you mean "0.8 to 0.99"? Third, please give some examples of how a number should be rounded. Mar 8, 2022 at 6:10
• Please share a link to a spreadsheet with realistic sample data already entered, as well as your hand-entered results for what you'd like to see the formula returning. I agree with Tedinoz: your sets are off. I think you mean something like {0.01 - 0.05, 0.06 - 0.29, etc.} Mar 8, 2022 at 6:43
• You are right. The secuence is: Mar 9, 2022 at 14:12

Use `ifs()`, like this:

``````=ifs(
A2 < 0.01, na(),
A2 <= 0.05, 0,
A2 <= 0.29, 0.25,
A2 <= 0.55, 0.5,
A2 <= 0.8, 0.75,
A2 <= 1, 1,
true, na()
)
``````
• The OP's sequence of percentages is topsy turvy, but I wonder whether the first condition shouldn't be `A2<0.01`? Mar 13, 2022 at 7:40
• Edited the answer. Mar 13, 2022 at 21:56
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://webapps.stackexchange.com/questions/163357/can-i-create-an-if-formula-to-round-decimals-with-differents-statements", "fetch_time": 1680426672000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-14/segments/1679296950422.77/warc/CC-MAIN-20230402074255-20230402104255-00276.warc.gz", "warc_record_offset": 695050375, "warc_record_length": 37263, "token_count": 610, "char_count": 1804, "score": 3.734375, "int_score": 4, "crawl": "CC-MAIN-2023-14", "snapshot_type": "latest", "language": "en", "language_score": 0.9191142916679382, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00012-of-00064.parquet"}