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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Analitika
Post Prodigy
Post Prodigy

Switch filter not works well in Power BI

Hello,

 

I would like to make that if user select filter box it getting different values. Filter 

Analitika_0-1653570094768.png

I am having three different cases:

If I select Be kasos I should get value 

measure[USED Pardavimai be kasu],
if selected Su kasa then 
[USED OK Pardavimai]
If selects both 
[USED OK Pardavimai].
But I am having issue that Be kasos case not working.
Sales Amount =
SWITCH (
TRUE (),
MAX('Pajamu vaizdavimas'[Parinkimas 4]) IN { "Be kasos", "Su kasa"}, [USED OK Pardavimai],
MAX('Pajamu vaizdavimas'[Parinkimas 4]) = "Be kasos", [USED Pardavimai be kasu],
MAX('Pajamu vaizdavimas'[Parinkimas 4]) = "Su kasa", [USED OK Pardavimai],
0
)This is the formula
second max not works for me.
How to resolve this?
MAX('Pajamu vaizdavimas'[Parinkimas 4]) = "Be kasos", [USED Pardavimai be kasu], this is not used somehow
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Analitika ,

 

I create a sample to have a test. I think you can try this code to achieve your goal.

Sales Amount =
VAR _COUNT =
    CALCULATE ( DISTINCTCOUNT ( 'Pajamu vaizdavimas'[Parinkimas 4] ) )
RETURN
    IF (
        ISFILTERED ( 'Pajamu vaizdavimas'[Parinkimas 4] ),
        SWITCH (
            TRUE (),
            _COUNT = 2
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) IN { "Be kasos", "Su kasa" }, [USED OK Pardavimai],
            _COUNT = 1
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) = "Be kasos", [USED Pardavimai be kasu],
            _COUNT = 1
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) = "Su kasa", [USED OK Pardavimai],
            0
        ),
        0
    )

In my sample [USED Pardavimai be kasu] = 1 and [USED OK Pardavimai] = 2. Result is as below. 

No selection:

RicoZhou_0-1653898261346.png

Select Be kasos:

RicoZhou_1-1653898268161.png

Select Su kasa:

RicoZhou_2-1653898277552.png

Select Both:

RicoZhou_3-1653898284910.png

 

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.

 

 

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @Analitika ,

 

I create a sample to have a test. I think you can try this code to achieve your goal.

Sales Amount =
VAR _COUNT =
    CALCULATE ( DISTINCTCOUNT ( 'Pajamu vaizdavimas'[Parinkimas 4] ) )
RETURN
    IF (
        ISFILTERED ( 'Pajamu vaizdavimas'[Parinkimas 4] ),
        SWITCH (
            TRUE (),
            _COUNT = 2
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) IN { "Be kasos", "Su kasa" }, [USED OK Pardavimai],
            _COUNT = 1
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) = "Be kasos", [USED Pardavimai be kasu],
            _COUNT = 1
                && MAX ( 'Pajamu vaizdavimas'[Parinkimas 4] ) = "Su kasa", [USED OK Pardavimai],
            0
        ),
        0
    )

In my sample [USED Pardavimai be kasu] = 1 and [USED OK Pardavimai] = 2. Result is as below. 

No selection:

RicoZhou_0-1653898261346.png

Select Be kasos:

RicoZhou_1-1653898268161.png

Select Su kasa:

RicoZhou_2-1653898277552.png

Select Both:

RicoZhou_3-1653898284910.png

 

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.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors