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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Power BI Remove rows based on multiple conditions for dashboard

Hi all, 

 

I'm struggeling with the following issue:

 

I have a table which looks like this:

 

Countrysale status 

US

allowed 

GER

not allowed 

AUT

allowed 

GER

allowed 

 

My goal is to loop through the country column and identify duplicates and at the same time the command should check in case of duplicated values for a second condition which is "not allowed" in the column sales status. If the both conditions are matched the "not allowed" row should be removed completely from the table.

 

I hope you guys can help me out 🙂

 

Regards,

 

Elena

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi  @Anonymous ,

Try steps like  below:

base on table ,create a measure:

mark = 
VAR test1 =
    CALCULATE (
        COUNT ( 'Table'[sale status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[sale status] = "not allowed" )
    )
VAR test2 =
    CALCULATE (
        COUNT ( 'Table'[sale status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Country] = MAX ( 'Table'[Country] ) )
    )
RETURN
    IF (
        test1 >= 1
            && test2 > test1
            && MAX ( 'Table'[sale status] ) = "not allowed",
        0,
        1
    )

 

Step 2, custom  create new table:

Table 2 = CALCULATETABLE('Table',FILTER('Table','Table'[mark]=1))

 Output result:

vluwangmsft_0-1639990323950.png

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


Best Regards

Lucien

View solution in original post

3 REPLIES 3
Kate1053
New Member

This helped me get started, but the sample code was based on there being only one instance of "not allowed". Here is something that should be more flexible:

 

 

mark = 
VAR test =
    CALCULATE (
        COUNT ( 'Table'[sale status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Country] = MAX ( 'Table'[Country] ) )
    )
RETURN
    IF (
        test >= 2
        && MAX ( 'Table'[sale status] ) = "not allowed",
        0,
        1
    )

 

Also, you don't necessarily need the separate table. Just filter your visual/page/dashboard by the measure field.

 

v-luwang-msft
Community Support
Community Support

Hi  @Anonymous ,

Try steps like  below:

base on table ,create a measure:

mark = 
VAR test1 =
    CALCULATE (
        COUNT ( 'Table'[sale status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[sale status] = "not allowed" )
    )
VAR test2 =
    CALCULATE (
        COUNT ( 'Table'[sale status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Country] = MAX ( 'Table'[Country] ) )
    )
RETURN
    IF (
        test1 >= 1
            && test2 > test1
            && MAX ( 'Table'[sale status] ) = "not allowed",
        0,
        1
    )

 

Step 2, custom  create new table:

Table 2 = CALCULATETABLE('Table',FILTER('Table','Table'[mark]=1))

 Output result:

vluwangmsft_0-1639990323950.png

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


Best Regards

Lucien

smpa01
Super User
Super User

@Anonymous  can you please provide better dta; this dat does not seem to be reprentative of the issue you rae describing

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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