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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

 










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


Proud to be a Super User!









"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

 

 

 










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


Proud to be a Super User!









"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

 

 










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


Proud to be a Super User!









"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

 










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


Proud to be a Super User!









"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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

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

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.