Forum Discussion

rjg2g11's avatar
rjg2g11
Advocate I
7 years ago

SWITCH Measure with two visual level filters with multiple data sources

Hello, 

 

I have two visual level filters for two different levels - for example; 

 

Filter 1        Filter 2

1                  11

2                  12

3                  13

                    22

                    23

 

When you filter on 1 on Filter 1, it will bring back 11, 12, 13 - 2 on Filter 2 will bring back 22, 23 etc

 

When i have Filter 1 Selected and then Filter 2 selected to bring back data for 22, for example, the data shows data for 2

 

My code is; 

 

VAR Filter1 =
    IF (
        HASONEVALUE ( 'Filter_Lookup'[Channel] ),
        VALUES ( 'Filter_Lookup'[Channel] ),
        BLANK ()
    )
VAR Filter2 =
    IF (
        HASONEVALUE ( 'Filter_Lookup_Team'[Team] ),
        VALUES ( 'Filter_Lookup_Team'[Team] ),
        BLANK ()
    )

RETURN
    SWITCH (
        TRUE (),
        Filter1 = "1", CALCULATE (
            SUM ( Target_Output[Value] ),
            FILTER ( Target_Output, Target_Output[Channel] = "KA" ),
            FILTER ( Target_Output, Target_Output[Type] = "NSV" )
        ),
        Filter1 = "2", CALCULATE (
            SUM ( Target_Output[Value] ),
            FILTER ( Target_Output, Target_Output[Channel] = "Vape" ),
            FILTER ( Target_Output, Target_Output[Type] = "NSV" )
        ),
        Filter2 = "22", CALCULATE (
            SUM ( Target_Output[Value] ),
            FILTER ( Target_Output, Target_Output[Channel] = "22" ),
            FILTER ( Target_Output, Target_Output[Type] = "NSV" )
        ),
        Filter2 = "23", CALCULATE (
            SUM ( Target_Output[Value] ),
            FILTER ( Target_Output, Target_Output[Channel] = "23" ),
            FILTER ( Target_Output, Target_Output[Type] = "NSV" )
        ), BLANK())

Is there a way when i select something from Filter2, the pre selection of Filter1 can be ignored? I have tired ALL(), ALLEXCEPT() etc etc

 

 

Many Thanks

 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rjg2g11,

     

    Switch function not support to calculate with summarize records or split result based on category. (For your scenario, it will check all cases which you list and return the first matched condition)

     

    In addition, if you can please share some sample data for test.

     

    Regards,

    Xiaoxin Sheng