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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
amtbew
Helper I
Helper I

Summarizing AND Logic from Slicer

I have a dataset that I'm using a slicer to filter AND Logic using the dax and methodology applied from this blog post - https://community.fabric.microsoft.com/t5/Community-Blog/Apply-AND-logic-in-the-slicer/ba-p/2881583

 

The slicer works as intended for the table I filter by the measure suggested by the blog article, but it doesn't work on additional tables.

 

Here's the full data set

amtbew_0-1704838052821.png

Here's my measure from the blog article. 

 

Comparison = IF (
    ISFILTERED ( 'Vendor ID Table'[Vendor ID] )
        && MAX ( 'Data'[Vendor ID] )
            IN ALLSELECTED ( 'Vendor ID Table'[Vendor ID] )
                && COUNTROWS ( 'Vendor ID Table' )
                    <= CALCULATE (
                        COUNT ( 'Data'[Vendor ID] ),
                        FILTER (
                            ALLSELECTED ( 'Data' ),
                            [Vendor ID]
                                IN ALLSELECTED ( 'Vendor ID Table'[Vendor ID] )
                                    && [Product ID] = MAX ( 'Data'[Product ID] )
                        )
                    ),
    1
)

 

 

I add the measure as a filter to a table and it works as I'd like in conjuction with a slicer. Only returns the products where both vendors have an entry (excludes P02).

amtbew_1-1704838148250.png

Wondering how I could get the following tables to also follow the same logic and remove the P02 entry as it's not a match. The above Dax measure doesn't work as it's directly looking for the Product ID in these tables, which don't contain it. 

amtbew_2-1704838278116.png

 

 

Here's the pbix. https://www.dropbox.com/scl/fi/gfrcvt2ewuejw070ylk3w/AndLogicSummary.pbix?rlkey=wy748oi30dho9f9sqz4n...

 

Thanks

1 ACCEPTED SOLUTION

I'm hoping this  one works:

Comparison 3 = 
VAR __VENDOR_COUNT =
    COUNTROWS ( 'Vendor ID Table' )
RETURN
    CALCULATE (
        SUMX (
            SUMMARIZE (
                Data,
                Data[Product ID],
                "CountNo",
                    CALCULATE (
                        DISTINCTCOUNT ( Data[Vendor ID] ),
                        ALLEXCEPT ( Data, Data[Product ID] ),
                        Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] )
                    )
            ),
            IF ( [CountNo] = __VENDOR_COUNT, 1 )
        ),
        FILTER ( Data, Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] ) )
    )

danextian_0-1705039026989.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @amtbew ,

 

The problem with your formula is that it returns 1 only if Product ID is visible but returns 1 at the total level thus  nothing is filtered.  Try this:

Comparison 2 = 
VAR __VENDOR_COUNT =
    COUNTROWS ( 'Vendor ID Table' )
RETURN
    SUMX (
        SUMMARIZE (
            Data,
            Data[Product ID],
            "CountNo",
                CALCULATE (
                    COUNTROWS ( Data ),
                    ALLEXCEPT ( Data, Data[Product ID] ),
                    Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] )
                )
        ),
        IF ( [CountNo] >= __VENDOR_COUNT, 1 )
    )
Amount Filtered = 
CALCULATE ( SUM ( Data[Spend] ), FILTER ( Data, [Comparison 2] <> BLANK () ) )

danextian_0-1704879709075.png

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian 

 

It works with the sample data, however if I add a 3rd Vendor, it doesn't seem to work as intended. The slicer is not excluding the 3rd vendor.

 

amtbew_0-1704896359187.png

 

Try this:

 

VAR __VENDOR_COUNT =
    COUNTROWS ( 'Vendor ID Table' )
RETURN
    SUMX (
        SUMMARIZE (
            Data,
            Data[Product ID],
            "CountNo",
                CALCULATE (
                    COUNTROWS ( Data ),
                    ALLEXCEPT ( Data, Data[Product ID] ),
                    Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] )
                )
        ),
        IF ( [CountNo] = __VENDOR_COUNT, 1 )
    )

danextian_0-1704950988900.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Still having trouble scaling it. Doesn't work when I add a 4th vendor. 

 

amtbew_0-1705010462646.png

V01 should be excluded as it's not selected. 

 

Also I assume the Amount Filtered should be updated to reference comparison 3.

 

Here's the pbix. https://www.dropbox.com/scl/fi/gfrcvt2ewuejw070ylk3w/AndLogicSummary.pbix?rlkey=wy748oi30dho9f9sqz4n...

I'm hoping this  one works:

Comparison 3 = 
VAR __VENDOR_COUNT =
    COUNTROWS ( 'Vendor ID Table' )
RETURN
    CALCULATE (
        SUMX (
            SUMMARIZE (
                Data,
                Data[Product ID],
                "CountNo",
                    CALCULATE (
                        DISTINCTCOUNT ( Data[Vendor ID] ),
                        ALLEXCEPT ( Data, Data[Product ID] ),
                        Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] )
                    )
            ),
            IF ( [CountNo] = __VENDOR_COUNT, 1 )
        ),
        FILTER ( Data, Data[Vendor ID] IN VALUES ( 'Vendor ID Table'[Vendor ID] ) )
    )

danextian_0-1705039026989.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian this one did the trick. Thank you so much for the help.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.