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
jdubs
Helper V
Helper V

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
mahoneypat
Employee
Employee

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
mahoneypat
Employee
Employee

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


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

Greg_Deckler
Super User
Super User

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.