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).
Your UCL would look like so: Everything in the first argument will be filtered by ALLSELECTED. But ALLSELECTED is just used once:
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.S( 'Estimate vs actual'[Variance EvA] ) -- STDEV
* (2,66),
ALLSELECTED( 'Estimate vs actual' )
)
..
RETURN
IF (
'Estimate vs actual'[Variance EvA]
>= LCL
&& 'Estimate vs actual'[Variance EvA]
<= UCL,
"No Outlier",
"Outlier"
)
Hang on: Why do you apply ALLSELECTED to the whole (fact) table instead just on the Date-column of your calendar table?
.. if you're using the INDEX-column from your fact table on your chart, you should use ALLSELECTED just on that column.
- swestendorp6 years agoHelper I
Hi ImkeF
I am at a loss here. I've done as you suggested, but still I get only the right results when I remove the date filter. I also get results for rows that should be filtered out.
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 ( 'Estimate vs actual'[Variance EvA] >= LCL && 'Estimate vs actual'[Variance EvA] <= UCL , "No Outlier", "Outlier" )- ImkeF6 years agoCommunity Champion
From which table does your date-filter come from?
- ImkeF6 years agoCommunity Champion
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).