cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ramshoney1225
Helper IV
Helper IV

How to write Filter condition on with two different tables ?

Hi,

 

I want to write a DAX, i have two tables Tablea and tableb both are joined

i need to count and count distnct measure

 

COUNTID = count(id) based on tablea.id = tableb.id and tablea.type = "Protect"

 

I need to get count based on the two conditions in DAX

table( id )= tableb ( id ) and Tablea.type = "Protect" on

 

Thanks

Rams

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@ramshoney1225 , Assume both tables has a relation ID column

Try like

calculate(count(tablea[ID]), tablea[type] = "Protect", not(isblank(tableb[ID])))

or

calculate(count(tablea[ID]),filter(tablea, tablea[type] = "Protect" && tablea[ID]= related(tableb[ID])))

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

Thanks for the update,

 

I'm able to use the 2nd one , i didnt understand the first one.

 

If i dont need any hard code filter in that can i use as below right ?

 

calculate(
count('tablea'[ID]),
FILTER('tablea ,'tablea'[ID] = related('tableb'[ID]))       --- Where i have relation between two tables 
)
 
Thanks
Rams

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@ramshoney1225 , Assume both tables has a relation ID column

Try like

calculate(count(tablea[ID]), tablea[type] = "Protect", not(isblank(tableb[ID])))

or

calculate(count(tablea[ID]),filter(tablea, tablea[type] = "Protect" && tablea[ID]= related(tableb[ID])))

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

Thanks for the update,

 

I'm able to use the 2nd one , i didnt understand the first one.

 

If i dont need any hard code filter in that can i use as below right ?

 

calculate(
count('tablea'[ID]),
FILTER('tablea ,'tablea'[ID] = related('tableb'[ID]))       --- Where i have relation between two tables 
)
 
Thanks
Rams

View solution in original post

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!