Forum Discussion
Switch command including filter
- Anonymous3 years ago
Hi koorosh ,
Try this code.
DynamicMeasure = VAR _SELECT = SELECTEDVALUE ( MeasureListTable[MeasureTitle] ) RETURN SWITCH ( _SELECT, "More than 60", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 60 ) ), "More than 100", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 100 ) ), "More than 900", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 900 ) ), CALCULATE(SUM('Table'[DifferenceDays])) )Result:
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi koorosh ,
I suggest you to try code as below to create a measure.
DynamicMeasure =
VAR _SELECT =
SELECTEDVALUE ( MeasureListTable[MeasureTitle] )
RETURN
SWITCH (
_SELECT,
"More than 60",
CALCULATE (
SUM ( 'Table'[DifferenceDays] ),
FILTER ( 'Table', 'Table'[DifferenceDays] > 60 )
),
"More than 100",
CALCULATE (
SUM ( 'Table'[DifferenceDays] ),
FILTER ( 'Table', 'Table'[DifferenceDays] > 100 )
),
"More than 900",
CALCULATE (
SUM ( 'Table'[DifferenceDays] ),
FILTER ( 'Table', 'Table'[DifferenceDays] > 900 )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks. But we want to have all data in table visual when no option is selected. In this way, the visual would be empty.
- Anonymous3 years agoNot applicable
Hi koorosh ,
Try this code.
DynamicMeasure = VAR _SELECT = SELECTEDVALUE ( MeasureListTable[MeasureTitle] ) RETURN SWITCH ( _SELECT, "More than 60", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 60 ) ), "More than 100", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 100 ) ), "More than 900", CALCULATE ( SUM ( 'Table'[DifferenceDays] ), FILTER ( 'Table', 'Table'[DifferenceDays] > 900 ) ), CALCULATE(SUM('Table'[DifferenceDays])) )Result:
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- koorosh3 years ago
Post Partisan
Could you please check my last question?
https://community.fabric.microsoft.com/t5/Desktop/Joint-table/m-p/3323771#M1109821