Forum Discussion
Filtering a measure doesn't work in Aggregated Context
- 7 years ago
I think I've found a solution using an inner join which gives 1 in the test sampleset. Thanks Kristjan76 for giving me a hint why it wasn't working.
[Enabled Devices: [Devices]] + Enabled 2] =VAR tbl = ADDCOLUMNS(SUMMARIZE( Table1,Table1[Device],"Number of Enabled Sessions", CALCULATE(SUM(Table1[Sessions]), Table1[Is Enabled] = true),"Number of All Sessions", SUM(Table1[Sessions])),"Percentage of Enabled Sessions", DIVIDE([Number of Enabled Sessions], [Number of All Sessions]))RETURNCALCULATE([Devices], FILTER(NATURALINNERJOIN(tbl, Table1), [Percentage of Enabled Sessions] >= 0.5))
[Enabled Devices: [Devices]] + Enabled] = VAR tbl = ADDCOLUMNS( SUMMARIZE( Table1; Table1[Device]; "Number of Enabled Sessions"; CALCULATE(SUM(Table1[Sessions]); Table1[Is Enabled] = true); "Number of All Sessions"; SUM(Table1[Sessions]) ); "Enable";DIVIDE([Number of Enabled Sessions]; [Number of All Sessions]) ) RETURN COUNTROWS( FILTER( tbl; [Enable]>0,5 ) )
- Peter_7 years ago
Resolver I
That gives the correct count, but is it possible to do this by calling a [Devices] measure within the parent measure and not calculate it in place? In other words, can I filter the table just to devices that pass the [Percentage of Enabled Sessions ] check and hand that off to the [Devices] measure to apply any further filters? So instead of doing the commented version from Kristjan76's solution, which gives 1, to the uncommented one, which gives 2,?
[Enabled Devices: [Devices]] + Enabled 2] =VAR tbl = ADDCOLUMNS(SUMMARIZE( Table1,Table1[Device],"Number of Enabled Sessions", CALCULATE(SUM(Table1[Sessions]), Table1[Is Enabled] = true),"Number of All Sessions", SUM(Table1[Sessions])),"Percentage of Enabled Sessions", DIVIDE([Number of Enabled Sessions], [Number of All Sessions]))
RETURN
// COUNTROWS(FILTER(tbl, [Percentage of Enabled Sessions] >= 0.5))
CALCULATE( [Devices], FILTER(tbl, [Percentage of Enabled Sessions] >= 0.5))- Peter_7 years ago
Resolver I
I think I've found a solution using an inner join which gives 1 in the test sampleset. Thanks Kristjan76 for giving me a hint why it wasn't working.
[Enabled Devices: [Devices]] + Enabled 2] =VAR tbl = ADDCOLUMNS(SUMMARIZE( Table1,Table1[Device],"Number of Enabled Sessions", CALCULATE(SUM(Table1[Sessions]), Table1[Is Enabled] = true),"Number of All Sessions", SUM(Table1[Sessions])),"Percentage of Enabled Sessions", DIVIDE([Number of Enabled Sessions], [Number of All Sessions]))RETURNCALCULATE([Devices], FILTER(NATURALINNERJOIN(tbl, Table1), [Percentage of Enabled Sessions] >= 0.5))