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
acerNZ
Helper III
Helper III

Filter Multiple Columns for multiple filter options to create a Measure

CombineMeasure = CALCULATE(COUNT(Table[COL1]),FILTER(Table,(Table[Col1]="Completed"))) -- > Works (For one column)

but I need to filter and combine with 3 other options of 2 other columns

Please may I know how ?

But I have Col1 - > 2 filters AND (Table[COL1] ="Yes", Table[COL1] ="Not Sure")

Col2 -> AND(Table[Col2]="Yes", Table[Col2]<>"Not Sure", Table[Col2]="Parked")

Col3 -> AND(Table[Col3]="No", Table[Col3]<>"No Order ", Table[Col3]="New York")

Please may I know how to combine all above to create a measure to be used.

Thanks a ton

 

1 ACCEPTED SOLUTION

Hi, @acerNZ 

According to your case link, I can understand your requirement clearly now, you can try this measure:

Min count =

var _col1=COUNTX(FILTER(ALL('Table'),[Col1] in {"Yes","Not sure"}),[Col1])

var _col2=COUNTX(FILTER(ALL('Table'),[Col2]<>"Not sure"&&[Col2] in {"Yes","Parked"}),[Col2])

var _col3=COUNTX(FILTER(ALL('Table'),[Col3]<>"No order"&&[Col3] in {"No","New York"}),[Col3])

return

IF(_col1<=_col2,IF(_col1<=_col3,_col1),IF(_col2<=_col3,_col2,_col3))

Then place the measure into a card chart to check if the value can be correct(My result is based on my test data):

v-robertq-msft_0-1618886738917.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
acerNZ
Helper III
Helper III

Thank you @v-robertq-msft 

I think this is the stepwise solution. Thanks a lot

v-robertq-msft
Community Support
Community Support

Hi, @acerNZ 

According to your description, I can roughly understand your requirement, it seems that you want to make one measure to filter the table based on three columns, right? I think you can try this measure and apply it as the filter of the table chart:

This is my test data based on your DAX formula:

v-robertq-msft_0-1618815555583.png

 

I created a measure like this:

Flag =

var _Col1=IF(MAX('Table'[Col1]) in {"Yes","Not sure"},1,0)

var _Col2=IF(MAX('Table'[Col2])<>"Not sure"&&MAX('Table'[Col2]) in {"Yes","Parked"},1,0)

var _Col3=IF(MAX('Table'[Col3])<>"No order"&&MAX('Table'[Col3]) in {"No","New York"},1,0)

return

IF(_Col1+_Col2+_Col3=3,1,0)

Then I created a table chart like this:

v-robertq-msft_1-1618815555587.png

 

Then I apply a filter to the table chart to perform as the filter of the table:

v-robertq-msft_2-1618815555590.png

 

And you can get what you want.

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-robertq-msft Thank you for the response.

As there were multiple copies of this, I created another thread(Community is throwing fatal error on submission, but actually post is already submitted)

Refer:

https://community.powerbi.com/t5/Desktop/Count-of-Filter-of-Table-1-Col1-with-3-and-OR-Options-AND-T...

 

I have individually calculated each filter as you said. The easiest way is to say smallest of three as that is common. The question is how and if there are other straight forward ways 

Thanks a lot

Hi, @acerNZ 

According to your case link, I can understand your requirement clearly now, you can try this measure:

Min count =

var _col1=COUNTX(FILTER(ALL('Table'),[Col1] in {"Yes","Not sure"}),[Col1])

var _col2=COUNTX(FILTER(ALL('Table'),[Col2]<>"Not sure"&&[Col2] in {"Yes","Parked"}),[Col2])

var _col3=COUNTX(FILTER(ALL('Table'),[Col3]<>"No order"&&[Col3] in {"No","New York"}),[Col3])

return

IF(_col1<=_col2,IF(_col1<=_col3,_col1),IF(_col2<=_col3,_col2,_col3))

Then place the measure into a card chart to check if the value can be correct(My result is based on my test data):

v-robertq-msft_0-1618886738917.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

acerNZ
Helper III
Helper III

Hi @amitchandak Apologies, Not sure for all, but I wasn't able to post for many times until I saw your message to know that my post went through. I now see that the follow up question is above your response. This is to bring your attention. 

acerNZ
Helper III
Helper III

@amitchandak Thanks a lot Amit. I am trying to post multiple times, I was getting errors and it is a pleasant surprise to see your response. Thank you. 

If I understand you, well, I can extend the syntax you have given for any number of columns ? 

Please can you explain this statement, "Two tbale values can not be and , they need Or or IN" Does this mean only two options can be combined not 3 options ?

 

Thanks a lot

 

amitchandak
Super User
Super User

@acerNZ , Two tbale values can not be and , they need Or or IN

 

example 

 

CombineMeasure = CALCULATE(COUNT(Table[COL1]),FILTER(Table,(Table[Col1] in {"Yes", "Not Sure"})))

 

CombineMeasure = CALCULATE(COUNT(Table[COL1]),FILTER(Table,(Table[Col1] in {"Yes", "Not Sure"})))

 

1 or 2

CombineMeasure = CALCULATE(COUNT(Table[COL1]),FILTER(Table,(Table[Col1] in {"Yes", "Not Sure"}) || (Table[Col2]="Yes" || Table[Col2]<>"Not Sure" || Table[Col2]="Parked") ))

 

1 and 2

 

CombineMeasure = CALCULATE(COUNT(Table[COL1]),FILTER(Table,(Table[Col1] in {"Yes", "Not Sure"}) &&  (Table[Col2]="Yes" || Table[Col2]<>"Not Sure" || Table[Col2]="Parked") ))

 

add in this way

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.