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

Filter table based on value from another table

I have two tables ('Accounts' and 'Orders Created Last week' that have a relationship based on AccountID.

 

I want to create a new table filtering the Accounts table by those with Orders Created Last week. 

 

I have tried this,

 

'Accounts w/ Orders Last Week' = FILTER('Accounts', Accounts(AccountID) = RELATEDTABLE('Orders'[AccountID]))

 

...but I get the error that a "single value for AccountID cannot be determined" (which is technically correct as multiple Orders exist for each Account. So how do I filter this table?

 

 

1 ACCEPTED SOLUTION
Super User IV
Super User IV

This would be better done in the query editor or just do this filtering in your measure(s), but if not, please try this DAX table expression

 

'Accounts w/ Orders Last Week = FILTER('Accounts', Accounts[AccountID] in VALUES('Orders'[AccountID]))

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
Super User IV
Super User IV

This would be better done in the query editor or just do this filtering in your measure(s), but if not, please try this DAX table expression

 

'Accounts w/ Orders Last Week = FILTER('Accounts', Accounts[AccountID] in VALUES('Orders'[AccountID]))

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Thanks. I was using RELATEDTABLE instead of VALUES. That was my problem.

Super User IV
Super User IV

Perhaps:

 

'Accounts w/ Orders Last Week' = FILTER('Accounts', Accounts(AccountID) IN RELATEDTABLE('Orders'[AccountID]))

 

Otherwise, sample data and such would be very helpful. 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

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

Top Solution Authors
Top Kudoed Authors