Forum Discussion
Round Whole Number to nearest 5
I have column that has various whole numbers (1, 3, 37, 121, etc). I want to smooth variance in these numbers by rounding each to the nearest 5 (e.g. 1-->0, 3-->5, 37-->40, 121-->120). Any suggestions?
Hi Microbz ,
What is the logic behind rounding 3 to 5 while rounding 37 to 40 as the nearest multiples of 5? It seems that if 3 is rounded to 5, then by the same logic, 37 should be rounded to 35 instead of 40.
Assuming you meant that 37 should be rounded to 35 instead of 40, you can achieve the desired output using the following DAX formula:
Table = ADDCOLUMNS( GENERATESERIES(1, 1000, 1), "RoundedValue", ROUND([Value] / 5, 0) * 5 )The resulting output is shown below:
I have attached a sample PBIX file for your reference.
Best regards,
You could use the MROUND function in DAX to create a calculated column or measure, as follows.
New Column or Measure = MROUND([Name of Column with Numbers], 5)
Hope that helps.
If this answers your question, please mark as a solution so others can find.
2 Replies
- PowerBIDaveRegular Visitor
You could use the MROUND function in DAX to create a calculated column or measure, as follows.
New Column or Measure = MROUND([Name of Column with Numbers], 5)
Hope that helps.
If this answers your question, please mark as a solution so others can find.
- DataNinja777
Super User
Hi Microbz ,
What is the logic behind rounding 3 to 5 while rounding 37 to 40 as the nearest multiples of 5? It seems that if 3 is rounded to 5, then by the same logic, 37 should be rounded to 35 instead of 40.
Assuming you meant that 37 should be rounded to 35 instead of 40, you can achieve the desired output using the following DAX formula:
Table = ADDCOLUMNS( GENERATESERIES(1, 1000, 1), "RoundedValue", ROUND([Value] / 5, 0) * 5 )The resulting output is shown below:
I have attached a sample PBIX file for your reference.
Best regards,