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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jcarville
Skilled Sharer
Skilled Sharer

DAX Query - Rounding

Hi,

 

I have the following query to give me a recommended selling price for an item:

 

Recommended Selling Price =

IF(HASONEVALUE(SAGE_Extract[Symbol]),

            [Cost Price]

        + [Cost to Deliver]

        + [Haulage]

         - [Discount - Volume (£&€)])

 

I want to apply my own rounding rules so that if a selling price ends with a certain number a rule is applied e.g. ends with a 4 then round to 5, ends with a 6 then round to 5, ends with an 8 then round to 8.

 

I have tried using FORMAT to change the number to text, REPLACE and RIGHT to get the last character and a SWITCH function wrapped around this to give the different rounding options, but cannot get the DAX correct. Can anyone help?

 

Thanks.

 

 

1 ACCEPTED SOLUTION

Hi @jcarville,

 

A IF statement would help. Please try the formula below.

Column =
VAR lastDigital =
    INT ( RIGHT ( FIXED ( [Column1], 2 ), 1 ) )
RETURN
    IF (
        lastDigital IN { 0, 2, 3, 5, 7, 8 },
        [Column1],
        MROUND ( [Column1], 0.05 )
    )

Maybe you need to pay attention to the numbers end with 9.

DAX_Query_FORMAT_REPLACE_SWITCH2

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @jcarville,

 

Maybe the function MROUND could help.

Column = MROUND([Column1],0.3)

DAX_Query_FORMAT_REPLACE_SWITCH

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiascu-msft,

 

MROUND does not meet my requirements as can be seen below by the inconsistent values in my calculated column.

 

Capture.PNG

 

To be more specific, these are the roundings I need to apply:

 

Capture.PNG

 

 

Hi @jcarville,

 

A IF statement would help. Please try the formula below.

Column =
VAR lastDigital =
    INT ( RIGHT ( FIXED ( [Column1], 2 ), 1 ) )
RETURN
    IF (
        lastDigital IN { 0, 2, 3, 5, 7, 8 },
        [Column1],
        MROUND ( [Column1], 0.05 )
    )

Maybe you need to pay attention to the numbers end with 9.

DAX_Query_FORMAT_REPLACE_SWITCH2

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft, amazing DAX knowledge! That works perfectly to suit my needs. A bit heavy on the processing side, but my model is large anyways.

 

Thanks for your help with this, much appreciated.

 

Jake

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.