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
bob57
Helper IV
Helper IV

Calculated Column

Hello,

I'm hoping that someone can provide me with the DAX to accomplish the following

Thank you for your time,

Bob

Here is the raw data:

bob57_0-1659363626938.png

I need to add the calculated column, Difference:

bob57_1-1659363761671.png

Pseudo code: Rating - Base Rating for each match:

bob57_2-1659364143678.png

 

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

Hi @bob57 
Here is a sample file with the solution https://we.tl/t-KWLD6ZeAMf

Difference = 
VAR CurrentBase = Data[Base]
VAR CurrentRating = Data[Rating]
VAR CurrentMatchYesRating = CALCULATE ( MAX ( Data[Rating] ), ALLEXCEPT ( Data, Data[Match] ), Data[Base] = "yes" )
VAR Result =
    IF (
        CurrentBase = "no",
        CurrentRating - CurrentMatchYesRating,
        0
    )
RETURN
    ROUNDDOWN ( Result, 0 )

You may need to readjust the rounding type as per your requirement. 

View solution in original post

5 REPLIES 5
tamerj1
Community Champion
Community Champion

Hi @bob57 
Here is a sample file with the solution https://we.tl/t-KWLD6ZeAMf

Difference = 
VAR CurrentBase = Data[Base]
VAR CurrentRating = Data[Rating]
VAR CurrentMatchYesRating = CALCULATE ( MAX ( Data[Rating] ), ALLEXCEPT ( Data, Data[Match] ), Data[Base] = "yes" )
VAR Result =
    IF (
        CurrentBase = "no",
        CurrentRating - CurrentMatchYesRating,
        0
    )
RETURN
    ROUNDDOWN ( Result, 0 )

You may need to readjust the rounding type as per your requirement. 

That did the trick! Thank you so much.

bob57
Helper IV
Helper IV

My apologies. I neglected to mention that the calculation must be rounded to the nearest whole number.

tamerj1
Community Champion
Community Champion

Hi @bob57 

howdid you calculate the Difference?

I did it by hand for demonstration purposes. But the algorithm would go like this:

 

For each Match (1, 2, and 3) subtract the Base Rating (Rating where Base = yes) from the Rating and round to the nearest whole.

 

The calculation must be independent for the match so for Match = 2, for example:

when Tee = Red, then 65.4 - 69.7 = -4

when Tee = White, then 69.7 – 69.7 = 0

when Tee = Blue, then 71.3 – 69.7 = 2

 

I hope this offers the required clarity.

 

Bob

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.