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
ihungko
Frequent Visitor

How to use KEEPFILTERS with multiple OR conditions

I am trying to create a table using KEEPFILTERS with multiple OR conditions, but it seems that KEEPFIlTERS can only support AND relationships.

 

My scenario:

I want to filter out [Column 1], [Column 2], and [Amount] based on the conditions of [Type] OR [Category]. But KEEPFILTERS only allows an AND relationships. I want to see data that either matches [Type] condition OR [Category] condition.

EVALUATE
SUMMARIZECOLUMNS(
    [Column 1],
    [Column 2],
    KEEPFILTERS(
        TREATAS({XYZ},Type[Type])
        ),
    KEEPFILTERS(
        TREATAS({ABC},Catergory[Category])
        ),
    [Amount]
)

 

 

Can anyone please tell me how to write the code? Thanks!

1 ACCEPTED SOLUTION
rubayatyasmin
Super User
Super User

Hi, @ihungko 

 

try to use union. 

 

here is the documentation. UNION function (DAX) - DAX | Microsoft Learn

 

example code

 

DEFINE
    TABLE TypeFilter = 
        CALCULATETABLE (
            'YourTable', 
            TREATAS ( { "XYZ" }, 'YourTable'[Type] )
        )
    TABLE CategoryFilter = 
        CALCULATETABLE (
            'YourTable', 
            TREATAS ( { "ABC" }, 'YourTable'[Category] )
        )
EVALUATE
    SUMMARIZECOLUMNS (
        [Column 1],
        [Column 2],
        UNION ( TypeFilter, CategoryFilter ),
        [Amount]
    )

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

1 REPLY 1
rubayatyasmin
Super User
Super User

Hi, @ihungko 

 

try to use union. 

 

here is the documentation. UNION function (DAX) - DAX | Microsoft Learn

 

example code

 

DEFINE
    TABLE TypeFilter = 
        CALCULATETABLE (
            'YourTable', 
            TREATAS ( { "XYZ" }, 'YourTable'[Type] )
        )
    TABLE CategoryFilter = 
        CALCULATETABLE (
            'YourTable', 
            TREATAS ( { "ABC" }, 'YourTable'[Category] )
        )
EVALUATE
    SUMMARIZECOLUMNS (
        [Column 1],
        [Column 2],
        UNION ( TypeFilter, CategoryFilter ),
        [Amount]
    )

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


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.

Top Solution Authors