Forum Discussion

koorosh's avatar
koorosh
Post Partisan
3 years ago
Solved

Switch command including filter

Hi, Please check the attached file (testdays.pbix). I need a command to add to the switch command in the measure 'Dynamicmeasure' so that the slicer can filter the visual table on page one based on t...
  • Anonymous's avatar
    Anonymous
    3 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 Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.