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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TCavins
Helper V
Helper V

Measure Filter

I've combined 2 datasets into one for a map in Power BI. Lets call them People and Centers. I've added a column called IsPerson, setting it to either 1 or 0 based on the dataset.

 

Here's a sample of a table I created for testing. Value1 represents my InPerson column that I created in the datasets.

Table 2 = {
    (1, "Red", "Car", , ,),
    (1, "Blue", "Truck", , ,),
    (1, "Red", "Motorcycle",,,),
    (1, "Blue", "Car",,,),
    (0,,,"Group 1","County A", "Some Center Value"),
    (0,,,"Group 1", "County B","Center only value"),
    (0,,,"Group 2", "County A", "Center value goes here")
    }


I want slicers to be able to filter Value 2 and Value 3 for people. Then other slicers will filter Value 4 and Value 5 for Centers.

If I filter on "Red" and "County A", I want rows 1,3,5, and 7 in the results.

 

If I filter on "Red" and "Motorcycle", I want rows 3,5,6, and 7.

"Blue", "Group 2", I want rows 2 and 7.

"Group 2", I want rows 1,2,3,4, and 7.

 

Any ideas?

5 REPLIES 5
amitchandak
Super User
Super User

@TCavins , You need to create independent tables with distinct values value 2 and value 3 and use them in slicer and then create measure like this and use it value 2 and value 3 or original table

 

countrows(filter(Table, Table[Value2] in values('value 2'[Value 2]) || Table[Value 3] in values('value 2'[Value3]) ) )

 

Need of an Independent Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Would it be similar to this since I only want if it's selected?

MeasureFilter =
COUNTROWS(FILTER('Table 2', 'Table 2'[Value2] IN ALLSELECTED(val2s[Value2]) || 'Table 2'[Value3] IN ALLSELECTED(val3s[Value3]) || 'Table 2'[Value4] IN ALLSELECTED(val4s[Value4])|| 'Table 2'[Value5] IN ALLSELECTED(val5s[Value5])))

From there, how do filter out the original table to be displayed?

@amitchandak I think I'm close. The following works if I have filtered either value 2 or 3 and filtered value 4 or value 5. Any other combinations don't seem to work.

I placed this measure on a visual level filter and set it = 1 but selected just "Blue" doesn't work. Selected "Blue" and "Car" doesn't work. "Blue" and "Group 1" works. "Blue", "Car", and "Group 1" works. Just "Group 1" doesn't work, etc.

MeasureFilter = 
//COUNTROWS(FILTER('Table 2', 'Table 2'[Value2] IN ALLSELECTED(val2s[Value2]) || 'Table 2'[Value3] IN ALLSELECTED(val3s[Value3]) || 'Table 2'[Value4] IN ALLSELECTED(val4s[Value4])|| 'Table 2'[Value5] IN ALLSELECTED(val5s[Value5])))

    IF(
        (
            (
                SELECTEDVALUE('Table 2'[Value2]) IN ALLSELECTED(val2s[Value2])  || NOT(ISFILTERED(val2s[Value2]))
            )
            &&
            ( 
                SELECTEDVALUE('Table 2'[Value3]) IN ALLSELECTED(val3s[Value3]) || NOT(ISFILTERED(val3s[Value3]))
            )
        )
        ||
        (
            ( 
                SELECTEDVALUE('Table 2'[Value4]) IN ALLSELECTED(val4s[Value4]) || NOT(ISFILTERED(val4s[Value4]))
            )
            &&
            ( 
                SELECTEDVALUE('Table 2'[Value5]) IN ALLSELECTED(val5s[Value5]) || NOT(ISFILTERED(val5s[Value5]))
            )
        ),
        1,
        0
    )

 

Initial testing of the following seems to work:

MeasureFilter = 

    IF(
        
        (SELECTEDVALUE('Table 2'[Value1]) = 1 && OR(
                    NOT(ISFILTERED(val2s[Value2])) ,
                    SELECTEDVALUE('Table 2'[Value2]) IN ALLSELECTED(val2s[Value2])
                )
        &&
        SELECTEDVALUE('Table 2'[Value1]) = 1 && OR(
                    NOT(ISFILTERED(val3s[Value3])) ,
                    SELECTEDVALUE('Table 2'[Value3]) IN ALLSELECTED(val3s[Value3])
                )
        )
        ||
        (
        SELECTEDVALUE('Table 2'[Value1]) = 0 && OR(
                    NOT(ISFILTERED(val4s[Value4])) ,
                    SELECTEDVALUE('Table 2'[Value4]) IN ALLSELECTED(val4s[Value4])
                )
         &&
        SELECTEDVALUE('Table 2'[Value1]) = 0 && OR(
                    NOT(ISFILTERED(val5s[Value5])) ,
                    SELECTEDVALUE('Table 2'[Value5]) IN ALLSELECTED(val5s[Value5])
                )
        )
        ,
        1,
        0
    )

@amitchandak 

When I apply this measure as a filter to a ESRI map that has a large amount of points, I do not get the as many records as I should. I am only seeing a handful of points where I should see a few hundred. Using the same data and same filter with a table displaying the data, I get the number of rows that I expect.


Any thoughts?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.