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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiple filter conditions

Hi,

 

I got the table DimCompanyHis (it contains more columns but these are not relevant for the filtering).
company category and company subcategory are textual columns.

Company nameCompany categoryCompany subcategory
A125
B128
C133
D133
E1-
F218
G2-
H2-
I312
J433

 

I need to filter out companies:

1. Company category = "2"
OR
2. Company category = "1" AND Company subcategory = "33"

This is too much for the regular Power BI filter options so I need DAX.
I tried a query with CALCULATEDTABLE but I got the scalar value vs multiple value error.

Any ideas?
Thx in advance!

6 REPLIES 6
parry2k
Super User
Super User

@Anonymous try following measure

 

Your Measure = 
CALCULATE( SUM(Table[Sales]),
Company[Company Category]="2" ||
AND( Company[Company Category] = "1", Company[Compay Subcategory]="33")
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Why the SUM?
My category and subcategory are textual values (saying this I know that I could have created better example data:-) ).

@Anonymous sum was just to show how to apply or condition in your measures.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k ,

I used the query (and changed the corresponding columns) and got the following error:
"The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression." 

Why can't AND handle this?

@Anonymous missed to add filter

 

Your Measure = 
CALCULATE( SUM(Table[Sales]),
FILTER(
Company,
Company[Company Category]="2" ||
AND( Company[Company Category] = "1", Company[Compay Subcategory]="33")
)
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k I still don't understand what the correct query is and why I need SUM. 
SUM gives me an error since my data consists of strings instead of numbers.

But if I don't use the SUM I get the following error: "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value".

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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