Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rjg2g11
Advocate I
Advocate I

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 1
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.