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
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
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.

Top Solution Authors