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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

URGENT!! Measure that ignores slicers/ filters

Hello Power BI community,

 

Can you help me modify this code such that if I use SankeyTable'[Category_Planning] as a slicer in my power bi report and filter any one of its values, this measure should be able to ignore the SankeyTable'[Category_Planning] slicer and always keeps all the 4 values of  SankeyTable'[Category_Planning]  in the calculation?

@MFelix , @amitchandak , @Ashish_Mathur 

DistinctCount_Category_Occasions_MultiSelect_Part12 =
VAR CategorySelection = ISFILTERED('df_Category Purchased'[Category Purchased])
VAR SelectedChannel = SELECTEDVALUE('df_Category Purchased'[Category Purchased])
RETURN
    IF (
        CategorySelection,
        IF (
            Not SelectedChannel IN { "JUICE", "SPORTS DRINKS", "PACKAGED WATER", "RTD TEA"},
            (SUMX(VALUES(df_Barriers_SSD[Barriers_SSD]),
            CALCULATE(
                DISTINCTCOUNT('Respondent'[Unique_ID]),
                'df_Occasions'[value1] = "Yes",'SankeyTable'[Category_Planning] IN {"Decided", "", "Open/Considered", "Not Answered"},
                FILTER(
                    'Respondent',
                    [IsBarriersSSD]
                )
            ))),
            BLANK ()
        ), (SUMX(VALUES(df_Barriers_SSD[Barriers_SSD]),
            CALCULATE(
                DISTINCTCOUNT('Respondent'[Unique_ID]),
                'df_Occasions'[value1] = "Yes",'SankeyTable'[Category_Planning] IN {"Decided", "", "Open/Considered", "Not Answered"},
                FILTER(
                    'Respondent',
                    [IsBarriersSSD]
                )
            )))
    )

 

 

 
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous 

 

Try the following code:

DistinctCount_Category_Occasions_MultiSelect_Part12 =
VAR CategorySelection =
    ISFILTERED ( 'df_Category Purchased'[Category Purchased] )
VAR SelectedChannel =
    SELECTEDVALUE ( 'df_Category Purchased'[Category Purchased] )
RETURN
    IF (
        CategorySelection,
        IF (
            NOT SelectedChannel IN { "JUICE", "SPORTS DRINKS", "PACKAGED WATER", "RTD TEA" },
            (
                SUMX (
                    VALUES ( df_Barriers_SSD[Barriers_SSD] ),
                    CALCULATE (
                        DISTINCTCOUNT ( 'Respondent'[Unique_ID] ),
                        'df_Occasions'[value1] = "Yes",
                        'SankeyTable'[Category_Planning]
                            IN { "Decided", "", "Open/Considered", "Not Answered" },
                        REMOVEFILTERS ( 'SankeyTable'[Category_Planning] ),
                        FILTER ( 'Respondent', [IsBarriersSSD] )
                    )
                )
            ),
            BLANK ()
        ),
        (
            SUMX (
                VALUES ( df_Barriers_SSD[Barriers_SSD] ),
                CALCULATE (
                    DISTINCTCOUNT ( 'Respondent'[Unique_ID] ),
                    'df_Occasions'[value1] = "Yes",
                    'SankeyTable'[Category_Planning]
                        IN { "Decided", "", "Open/Considered", "Not Answered" },
                    REMOVEFILTERS ( 'SankeyTable'[Category_Planning] ),
                    FILTER ( 'Respondent', [IsBarriersSSD] )
                )
            )
        )
    )

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous 

 

Try the following code:

DistinctCount_Category_Occasions_MultiSelect_Part12 =
VAR CategorySelection =
    ISFILTERED ( 'df_Category Purchased'[Category Purchased] )
VAR SelectedChannel =
    SELECTEDVALUE ( 'df_Category Purchased'[Category Purchased] )
RETURN
    IF (
        CategorySelection,
        IF (
            NOT SelectedChannel IN { "JUICE", "SPORTS DRINKS", "PACKAGED WATER", "RTD TEA" },
            (
                SUMX (
                    VALUES ( df_Barriers_SSD[Barriers_SSD] ),
                    CALCULATE (
                        DISTINCTCOUNT ( 'Respondent'[Unique_ID] ),
                        'df_Occasions'[value1] = "Yes",
                        'SankeyTable'[Category_Planning]
                            IN { "Decided", "", "Open/Considered", "Not Answered" },
                        REMOVEFILTERS ( 'SankeyTable'[Category_Planning] ),
                        FILTER ( 'Respondent', [IsBarriersSSD] )
                    )
                )
            ),
            BLANK ()
        ),
        (
            SUMX (
                VALUES ( df_Barriers_SSD[Barriers_SSD] ),
                CALCULATE (
                    DISTINCTCOUNT ( 'Respondent'[Unique_ID] ),
                    'df_Occasions'[value1] = "Yes",
                    'SankeyTable'[Category_Planning]
                        IN { "Decided", "", "Open/Considered", "Not Answered" },
                    REMOVEFILTERS ( 'SankeyTable'[Category_Planning] ),
                    FILTER ( 'Respondent', [IsBarriersSSD] )
                )
            )
        )
    )

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





Sahir_Maharaj
Super User
Super User

Hello @Anonymous,

 

Can you please try this:

DistinctCount_Category_Occasions_MultiSelect_Part12 =
VAR CategorySelection = ISFILTERED('df_Category Purchased'[Category Purchased])
VAR SelectedChannel = SELECTEDVALUE('df_Category Purchased'[Category Purchased])
RETURN
    IF (
        CategorySelection,
        IF (
            NOT SelectedChannel IN { "JUICE", "SPORTS DRINKS", "PACKAGED WATER", "RTD TEA" },
            SUMX(
                VALUES(df_Barriers_SSD[Barriers_SSD]),
                CALCULATE(
                    DISTINCTCOUNT('Respondent'[Unique_ID]),
                    'df_Occasions'[value1] = "Yes",
                    'SankeyTable'[Category_Planning] IN { "Decided", "", "Open/Considered", "Not Answered" },
                    FILTER(
                        ALL('SankeyTable'[Category_Planning]),  // This line removes the slicer/filter effect on Category_Planning
                        [IsBarriersSSD]
                    )
                )
            ),
            BLANK()
        ),
        SUMX(
            VALUES(df_Barriers_SSD[Barriers_SSD]),
            CALCULATE(
                DISTINCTCOUNT('Respondent'[Unique_ID]),
                'df_Occasions'[value1] = "Yes",
                'SankeyTable'[Category_Planning] IN { "Decided", "", "Open/Considered", "Not Answered" },
                FILTER(
                    ALL('SankeyTable'[Category_Planning]),  // This line removes the slicer/filter effect on Category_Planning
                    [IsBarriersSSD]
                )
            )
        )
    )

 


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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