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
manishgaikwad87
Frequent Visitor

Need to create 2 filters which will show "Has" and "Does Not have" option

I need help to create 2 slicers on one table. One with "Has" and Second with "Does Not Have".

 

Below is the table example which has "Customers", "Products" and "Products Price".

 

CustomersProductPrice
AINT1300
BINT1300
CINT1300
DCHB100
ECHB100
FCHB100
GWND2500
HWND2500
IWND2500
JECOM1700
KECOM1700
LECOM1700
MINT1300

 

There should be 2 slicers, one with "Has Product" and second slicer should be "Does Not have products" which should filter out customers who have one product and does not have other products.

 

I have put the above table in below matrix format:-

CustomersCHBECOMINTWNDGrand Total
A  1300 1300
B  1300 1300
C  1300 1300
D100   100
E100   100
F100   100
G   25002500
H   25002500
I   25002500
J 1700  1700
K 1700  1700
L 1700  1700
M  1300 1300
Grand Total30051005200750018100

 

The slicers should perform in such a way that when i select "INT" in "Has" slicer and "CHB" in "Does not have" slicer it should show me only those customers who has product as "INT" and does not have product as "CHB".

2 ACCEPTED SOLUTIONS
NamishB
Post Prodigy
Post Prodigy

Hi @manishgaikwad87 - there are many ways to do this. One of way as below-

Have 2 extra columns (HasINT) and (HasCHB)

formula for these would be something like- 

= Table.AddColumn(#"Changed Type", "HasInt", each if [INT] = null then "Does Not have" else "Has")

= Table.AddColumn(#"Added Custom", "HasCHB", each if [CHB] = null then "Does Not have" else "Has")

 

table in query editor looks like-

NamishB_0-1604004156468.png

 

In Report panel-

Add 2 slicers one for each HasInt and HasCHB (Make sure in Format> edit Interactions> Stop filtering each slicers based on selection)

 

 

NamishB_3-1604004383116.png 

NamishB_4-1604004394262.png

And you can filter whatever combination you want.

NamishB_5-1604004492304.png

 

Hope this helps.

 

Cheers,

-Namish B

 

 

 

 

 

 

 

 

View solution in original post

Hi, @manishgaikwad87 
First, you need to create two calculated tables as below:

Has Product = DISTINCT('Customer inventory'[Product])
Does Not Have Product = DISTINCT('Customer inventory'[Product])

Then create two visual control measure as below:

Condition1_has product =
VAR flag =
    IF (
        CALCULATE (
            MAX ( 'Customer inventory'[Price] ),
            FILTER (
                'Customer inventory',
                'Customer inventory'[Product] IN VALUES ( 'Has Product'[Product] )
                    = BLANK ()
            )
        ),
        0,
        1
    )
RETURN
    IF ( ISFILTERED ( 'Has Product' ), flag, 1 )
Condition2_does not have product =
VAR flag =
    IF (
        CALCULATE (
            MAX ( 'Customer inventory'[Price] ),
            FILTER (
                'Customer inventory',
                'Customer inventory'[Product] IN VALUES ( 'Does Not Have Product'[Product] )
                    <> BLANK ()
            )
        ),
        0,
        1
    )
RETURN
    IF ( ISFILTERED ( 'Does Not Have Product'[Product] ), flag, 1 )

Just drag them to visual filter pane,you will get the result as below:

34.png

Check attached pbix file for more details.

 

Best Regards,
Community Support Team _ Eason
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

3 REPLIES 3
manishgaikwad87
Frequent Visitor

Hi @NamishB ,

 

Thanks for your reply. But unfortunately the data in the query editor is in different format and hence was not able to try the below solution.

 

Attaching the images of the table and the outout which i am looking for. Hope this explains the concern in a better way:-

 

Table:

Table1.jpg

Output:

Output.jpg

Regards,

Manish.

Hi, @manishgaikwad87 
First, you need to create two calculated tables as below:

Has Product = DISTINCT('Customer inventory'[Product])
Does Not Have Product = DISTINCT('Customer inventory'[Product])

Then create two visual control measure as below:

Condition1_has product =
VAR flag =
    IF (
        CALCULATE (
            MAX ( 'Customer inventory'[Price] ),
            FILTER (
                'Customer inventory',
                'Customer inventory'[Product] IN VALUES ( 'Has Product'[Product] )
                    = BLANK ()
            )
        ),
        0,
        1
    )
RETURN
    IF ( ISFILTERED ( 'Has Product' ), flag, 1 )
Condition2_does not have product =
VAR flag =
    IF (
        CALCULATE (
            MAX ( 'Customer inventory'[Price] ),
            FILTER (
                'Customer inventory',
                'Customer inventory'[Product] IN VALUES ( 'Does Not Have Product'[Product] )
                    <> BLANK ()
            )
        ),
        0,
        1
    )
RETURN
    IF ( ISFILTERED ( 'Does Not Have Product'[Product] ), flag, 1 )

Just drag them to visual filter pane,you will get the result as below:

34.png

Check attached pbix file for more details.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

NamishB
Post Prodigy
Post Prodigy

Hi @manishgaikwad87 - there are many ways to do this. One of way as below-

Have 2 extra columns (HasINT) and (HasCHB)

formula for these would be something like- 

= Table.AddColumn(#"Changed Type", "HasInt", each if [INT] = null then "Does Not have" else "Has")

= Table.AddColumn(#"Added Custom", "HasCHB", each if [CHB] = null then "Does Not have" else "Has")

 

table in query editor looks like-

NamishB_0-1604004156468.png

 

In Report panel-

Add 2 slicers one for each HasInt and HasCHB (Make sure in Format> edit Interactions> Stop filtering each slicers based on selection)

 

 

NamishB_3-1604004383116.png 

NamishB_4-1604004394262.png

And you can filter whatever combination you want.

NamishB_5-1604004492304.png

 

Hope this helps.

 

Cheers,

-Namish B

 

 

 

 

 

 

 

 

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.