Forum Discussion
Use measure to evaluate row value
- 6 years ago
Hi swestendorp
the Outlier-"Measure" isn't a valid syntax for a measure, as it is missing aggregation-commands. With "SUM" as aggregation it would look like so and work as a measure:
Outlier = VAR UCL = CALCULATE( AVERAGEX( 'Estimate vs actual', 'Estimate vs actual'[Variance EvA] ) -- Mean + STDEV.S( 'Estimate vs actual'[Variance EvA] ) -- STDEV * (2,66), ALLSELECTED( 'Estimate vs actual' ) ) VAR LCL = CALCULATE( AVERAGEX( 'Estimate vs actual', 'Estimate vs actual'[Variance EvA] ) -- Mean - STDEV.P( 'Estimate vs actual'[Variance EvA] ) -- STDEV * (2,66), ALLSELECTED( 'Estimate vs actual' ) ) RETURN IF ( SUM('Estimate vs actual'[Variance EvA]) >= LCL && SUM('Estimate vs actual'[Variance EvA]) <= UCL , "No Outlier", "Outlier" )So you'd probably have used it as a column? Then of course, the ALLSELECTED wouldn't work, as it would only work on measures (columns values are calculated during load of the data model and are not aware of any filters on the report).
Please check out the attached file where I mocked up some things that should give food for thought (it's got some loose ends that might force you to rethink your requirements).
Hi swestendorp
Using variables should do the job here:
Outlier =
VAR LCL = [LCL]
VAR UCL = [UCL]
Return
IF (
'Estimate vs actual'[Variance EvA] >= LCL
&& 'Estimate vs actual'[Variance EvA] <= UCL,
"No Outlier",
"Outlier"
)
ALLSELECTED is a beast: https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/
- swestendorp6 years agoHelper I
Hi ImkeF !
Thanks so much for taking the time to look at my issue.The solution is working when I remove the date filter. So when I keep the date filter active, it still does not return the desired outcome. That's why I added the ALLSELECTED, to take into account my date filter. How can i fix this?
Best,
Sifra
- ImkeF6 years agoCommunity Champion
Hi swestendorp
what is shown in the picture you've posted?
The column values for UCL and LCL look alright? if they evluate the right boundaries, then using their expressions in the variables should return the desired result.
Also ALLSELECTED might interfere with each other. So please check if ALLSELECTED is used in any of the referenced measures.
- swestendorp6 years agoHelper I
Hi ImkeF,
Thanks for bearing with me 🙂
This is the situation (=not correct) when I have a date slicer active (which I want)
This is what it look's like (= correct) when I remove that date filter (which I don't want)
Best,
Sifra