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
C-Jac
Helper I
Helper I

Use measure in calculated row for multiple rows

I have a table which looks like this: 

 

Value: AbsValue:   InLast7Days:   IsSignificant:   
50050011
-60060011
-8,0008,00000

25,000   

25,00000
404010

 

I would like to make a column where we indicate whether or not the value is significant. This is based on the standard deviation formula: 

 

StDev:= CALCULATE( STDEV.P ( Value ) , InLast7Days = 1 ) = 451

 

In the IsSignificant I would like a flag to mark 1 if the AbsValue is larger than the standard deviation just calculated, and 0 if it is not larger. 

 

I've tried using the StDev measure in the calculated column IsSignificant, but then they all equal 1, and if I try and make the calculation within the calculated column instead, only the ones that are InPast7Days are 1 regardless of their value. 

 

I've found that the reason for this, is because if you just write the measure calculation as the calculated column, then they all equal 0, it seems that it is just calculating the standard deviation for the one row, but I need the 'total' measure in each individual row. 

 

Hope this makes sense, and that someone has an answer that can help me 🙂 

 

1 ACCEPTED SOLUTION
rfigtree
Resolver III
Resolver III

hope this helps.

When performing the STD calculation you need to tell CALCULATE which context you want to consider.

The context you described is all rows where the last seven days flag is one.

It can be a bit of a mind bender, but as grasped is amazingly powerful.

 

=var _STD=CALCULATE(STDEV.P(Table1[Value]),
                    filter(ALL(Table1),[InLast7Days]=1)
                    )
return if(Table1[AbsValue]>_STD && 
          Table1[InLast7Days]=1,
          1,0)

 

rfigtree_0-1613771901448.png

 

View solution in original post

2 REPLIES 2
rfigtree
Resolver III
Resolver III

hope this helps.

When performing the STD calculation you need to tell CALCULATE which context you want to consider.

The context you described is all rows where the last seven days flag is one.

It can be a bit of a mind bender, but as grasped is amazingly powerful.

 

=var _STD=CALCULATE(STDEV.P(Table1[Value]),
                    filter(ALL(Table1),[InLast7Days]=1)
                    )
return if(Table1[AbsValue]>_STD && 
          Table1[InLast7Days]=1,
          1,0)

 

rfigtree_0-1613771901448.png

 

This works so well, thank you so much! 
If i would like to add an additional filter to the _STD calculation, like an EstimateType which could be 1, 2 or 3, could I just add it like this?

=var _STD=CALCULATE(STDEV.P(Table1[Value]),
                    filter(ALL(Table1),[InLast7Days]=1)
                    , [EstimateType] = 2)


Or would I have to add it in a different way? 

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