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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Petegdl23
New Member

How to use or function with filters

I am getting ask to modify a report. I need to report revenue for a set of customers plus any customer that has aquired some specific products.

 

I am trying to use the below query but I am getting the error that filter is used in a True /False expession. 

 

Channel Customer = CALCULATE(sum('Finance fact_Revenue_Lines'[Total_Amount]), or(FILTER('Finance dim_GL_Item',CONTAINSSTRING('Finance dim_GL_Item'[Product_Level_2],"Product Name")), FILTER('All dim_Customer', CONTAINSSTRING('All dim_Customer'[Customer_Number],"4066-01"))))
1 ACCEPTED SOLUTION

I was able to solve it like this. I created two separate measures, one with filters by customer numbers and another one with products filtered. Then I created a third measure that sum boths and that's it.

View solution in original post

5 REPLIES 5
govindarajan_d
Super User
Super User

Hi @Petegdl23 ,

 

FILTER function returns a table and OR function is expecting a boolean result as the input. That's the reason you are getting an error that 'filter is used in a True /False expession.'

 

Please try this code and see if it works: 

I have used RELATED function to get the corresponding value of the Customer_Number. 

Channel Customer = CALCULATE (
    SUM ( 'Finance fact_Revenue_Lines'[Total_Amount] ),
    FILTER (
        'Finance dim_GL_Item',
        CONTAINSSTRING ( 'Finance dim_GL_Item'[Product_Level_2], "Product Name" )
            || CONTAINSSTRING ( RELATED ( 'All dim_Customer'[Customer_Number] ), "4066-01" )
    )
)

 

Upvote and accept as a solution if it helps!

I was able to solve it like this. I created two separate measures, one with filters by customer numbers and another one with products filtered. Then I created a third measure that sum boths and that's it.

You don't really need an explicit FILTER for this 

 

 

Channel Customer = CALCULATE (
    SUM ( 'Finance fact_Revenue_Lines'[Total_Amount] ),
    CONTAINSSTRING ( 'Finance dim_GL_Item'[Product_Level_2], "Product Name" )
    || CONTAINSSTRING ( 'All dim_Customer'[Customer_Number] , "4066-01" )
)

 

I don't think it will work:

1. Given that filter conditions that use two different columns cannot be written in this way

2. OP had not used ALL in his filter function. Implicit filters apply ALL on the table before filtering

 

For more info:

https://www.sqlbi.com/articles/specifying-multiple-filter-conditions-in-calculate/

@govindarajan_d you are right, I forgot about that limitation.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.