Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
anwarbi
Helper II
Helper II

Rounding down of Decimals in case of Ties

Hi, 

 

Can anyone please help me to fix the rounding of decimal value which is an average value resulting from a measure that i have created.

 

E.g.

In cases where the average value is 7.250 (a tie situation), when looked at single decimal, the result I am getting in power bi report is 7.3, however i want to have 7.2 as a result. (rounding up in case of ties).

 

And in other cases where the average value is 7.260 then it should be 7.3.

 

Appreciate your help.  @amitchandak 

1 ACCEPTED SOLUTION

@anwarbi ,

In DAX, I prefer using the SWITCH Statement.  Similar to IF, but I find it cleaner and easier.

Average result Rounded = SWITCH(
                             TRUE(),
                            ( [Average result]*10 - TRUNC( [Average result]*10, 0 )) <= .5, ROUNDDOWN(  [Average result], 1 ),
                            ROUNDUP( [Average result], 1 ))

Average result   Average result Rounded

7.25 7.2
7.26 7.3
1.25 1.2
1.26 1.3

Hope you are able to get this to work for you.

Regards,

View solution in original post

9 REPLIES 9
parry2k
Super User
Super User

@anwarbi yes it will not work for measure, you need to use DAX function ROUND ROUND function (DAX) - DAX | Microsoft Docs

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Not really sure, How round can be applies as it will be one directional Round up or down. 

 

I am looking to round down only incase where the value is tied.

@anwarbi ,

DAX has ROUNDUP and ROUNDOWN functions.  With these you can then specify how you want your Measure to be Rounded.

Regards,

I want to conditonally round down tie cases where the value is e.g. 1.25 so the result should be 1.2

 

but where the value is 1.26, I want them to round up to 1.3

@anwarbi ,

Are you able to share the Measure you are working with?  It would better help me to structure your Conditional Rounding.

I want the conditional round function to apply on the below measure. 

 
Average result= CALCULATE(AVERAGEX(VALUES('Country'[Company_names]),CALCULATE(AVERAGE('Table1'[points]),'Table1'[related companies]<>"",'Table1'[mapping]<>"")),ALL('Table1'[Company]))

@anwarbi ,

In DAX, I prefer using the SWITCH Statement.  Similar to IF, but I find it cleaner and easier.

Average result Rounded = SWITCH(
                             TRUE(),
                            ( [Average result]*10 - TRUNC( [Average result]*10, 0 )) <= .5, ROUNDDOWN(  [Average result], 1 ),
                            ROUNDUP( [Average result], 1 ))

Average result   Average result Rounded

7.25 7.2
7.26 7.3
1.25 1.2
1.26 1.3

Hope you are able to get this to work for you.

Regards,

parry2k
Super User
Super User

@anwarbi check this and apply as you see fit. Number.Round - PowerQuery M | Microsoft Docs

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I have to apply this on measure that I have created which calculates average value. I am not sure, how this can be applied to a measure?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.