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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rif_data
New Member

Show Category only Contains Multiple Selected Subcategory

I have a Data Set like this in PowerBI-

CategoryTotal ValueSub_Category
AB100A
AB100B
BC140B
BC140C
CX90C
CX90X
AX40A
AX40A
ABX200A
ABX200B
ABX200X


I want to use a slicer like this- if I multi select A and B in Slicer It will show only the category which has only A and B present (Category AB,ABX from my example). How can I do it?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rif_data ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sub category dimension table(DO NOT create any relationship with your fact table)

Sub Categories = VALUES('Table'[Sub_Category])

2. Create a measure as below

Flag = 
VAR _selsubcat =
    ALLSELECTED ( 'Sub Categories'[Sub_Category] )
VAR _selcount =
    COUNTROWS ( _selsubcat )
VAR _category =
    SELECTEDVALUE ( 'Table'[Category] )
VAR _subcategory =
    SELECTEDVALUE ( 'Table'[Sub_Category] )
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Sub_Category] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Category] = _category
                && 'Table'[Sub_Category] IN _selsubcat
        )
    )
RETURN
    IF ( _count = _selcount && _subcategory IN _selsubcat, 1, 0 )

3. Create a table visual

4. Apply a visual-level filter with the condition (Flag is 1) on the above able visual

vyiruanmsft_1-1735020088339.png

Best Regards

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @rif_data ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sub category dimension table(DO NOT create any relationship with your fact table)

Sub Categories = VALUES('Table'[Sub_Category])

2. Create a measure as below

Flag = 
VAR _selsubcat =
    ALLSELECTED ( 'Sub Categories'[Sub_Category] )
VAR _selcount =
    COUNTROWS ( _selsubcat )
VAR _category =
    SELECTEDVALUE ( 'Table'[Category] )
VAR _subcategory =
    SELECTEDVALUE ( 'Table'[Sub_Category] )
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Sub_Category] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Category] = _category
                && 'Table'[Sub_Category] IN _selsubcat
        )
    )
RETURN
    IF ( _count = _selcount && _subcategory IN _selsubcat, 1, 0 )

3. Create a table visual

4. Apply a visual-level filter with the condition (Flag is 1) on the above able visual

vyiruanmsft_1-1735020088339.png

Best Regards

This is EXACTLY WHAT I AM LOOKING FOR! 😊 
Thanks Mate!

Kedar_Pande
Super User
Super User

@rif_data 

Create a New Measure:

ShowCategory =
VAR SelectedSubCategories = VALUES('Table'[Sub_Category])
VAR CategorySubCategories =
CALCULATETABLE(
VALUES('Table'[Sub_Category]),
ALLEXCEPT('Table', 'Table'[Category])
)
VAR MatchCount = COUNTROWS(INTERSECT(SelectedSubCategories, CategorySubCategories))
VAR TotalSelected = COUNTROWS(SelectedSubCategories)
VAR TotalCategory = COUNTROWS(CategorySubCategories)
RETURN
IF(MatchCount = TotalSelected && MatchCount = TotalCategory, 1, 0)

Add this measure to the filter pane for the visual.
Set the filter to show only rows where ShowCategory = 1.

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Unfortunately this solution not working. 😦

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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