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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Adding two measures within an IF statement

Help! I'm trying to create a calculated column using an IF statement and need to add together 2 measures and compare the points value. Both measures are based on the "Points" column. The standard deviation is 12.5 and the average is 25.7 so together, they should equal 38.2. Since some of the point values are greater than 38.2, I would expect those values to have a Tier of "S" but instead, it is showing V for all of them. What am I doing wrong? 

 

Measure.PNG

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

The standard deviation and average measures are being computed in the current row context, they are not being computed against the whole dataset.

You'll need something like

 

Tier =
VAR _stdDev =
    CALCULATE ( [Standard deviation], ALL () )
VAR _avg =
    CALCULATE ( [Average], ALL () )
RETURN
    IF ( 'ASG Contribution Points'[Points] > ( _stdDev + _avg ), "S", "V" )

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Measure.PNG

Looks like stdDev and avg are reserved words in DAX, even though they're not function names. Just put an _ before them. I'll edit my original post to include that

Anonymous
Not applicable

that worked, thank you! 

johnt75
Super User
Super User

The standard deviation and average measures are being computed in the current row context, they are not being computed against the whole dataset.

You'll need something like

 

Tier =
VAR _stdDev =
    CALCULATE ( [Standard deviation], ALL () )
VAR _avg =
    CALCULATE ( [Average], ALL () )
RETURN
    IF ( 'ASG Contribution Points'[Points] > ( _stdDev + _avg ), "S", "V" )

 

Anonymous
Not applicable

I tried exactly that and am recieving this error:

 

The syntax for 'stdDev' is incorrect. (DAX(VAR stdDev = CALCULATE('ASG Contribution Points'[Standard Deviation], ALL())VAR avg = CALCULATE('ASG Contribution Points'[Average],ALL())RETURN IF ('ASG Contribution Points'[Points] > (stdDev + avg), "S", "V"))).

can you post a screenshot of the measure definition you are using?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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