cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
moustafa67
Helper I
Helper I

How do I filter this?

Hello,

I have a table with multiple columns. I need to count Column A, but only if it contains "TW/" or "TCH/". But it should only count if Column B contains the word "long". I managed to count the values with: 

X = calculate(COUNTROWS(Table),SEARCH("TW/",Table[A],,0)) + calculate(COUNTROWS(Table),SEARCH("TCH/",Table[A],,0))
How can I add a filter to only count if column B= "long" ?
 
Thanks in advance
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@moustafa67 , You can add like

X = calculate(COUNTROWS(Table),SEARCH("TW/",Table[A],,0) , [column B]= "long") + calculate(COUNTROWS(Table),SEARCH("TCH/",Table[A],,0) , [column B]= "long")

 

or try like

 

X = calculate(COUNTROWS(Table),filter( (SEARCH("TW/",Table[A],,0) >0 || SEARCH("TCH/",Table[A],,0) >0 )&& [column B]= "long"))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@moustafa67 , You can add like

X = calculate(COUNTROWS(Table),SEARCH("TW/",Table[A],,0) , [column B]= "long") + calculate(COUNTROWS(Table),SEARCH("TCH/",Table[A],,0) , [column B]= "long")

 

or try like

 

X = calculate(COUNTROWS(Table),filter( (SEARCH("TW/",Table[A],,0) >0 || SEARCH("TCH/",Table[A],,0) >0 )&& [column B]= "long"))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Both formulas can not add column B

oh my fault, it works perfect! BIG THANKS ❤️

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.