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
jwi1
Post Patron
Post Patron

searching for value in other table

Hi,

 

Hope someone can help me with the following.

 

I have 2 tables, see below.

 

I want to have a measure for table 1 which gives me the stock for each partnumber_sup from table 2.

As a joint is not advisable (the partnumber_sup gives a many to many relation and I have many other partnumbers in the same tables), I need some help.

 

Thanks!

 

table 1

warehousepartnumber_sup
0003065J
100003065J
204003065J
208003065J
212003065J
214003065J
216003065J
222003065J
224003065J

 

table 2

warehousepartnumber_supstock
0003065J2
204003065J1
208003065J3
212003065J0
214003065J1
216003065J3
222003065J2
224003065J1
417003065J0
1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @jwi1 

try like a

Measure = 
var _currentPartnumber = MAX(Table1[partnumber_sup])
RETURN
CALCULATE(DISTINCTCOUNT(Table2[stock]), FILTER(ALL(Table2), Table2[partnumber_sup] = _currentPartnumber) )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

4 REPLIES 4
az38
Community Champion
Community Champion

Hi @jwi1 

try like a

Measure = 
var _currentPartnumber = MAX(Table1[partnumber_sup])
RETURN
CALCULATE(DISTINCTCOUNT(Table2[stock]), FILTER(ALL(Table2), Table2[partnumber_sup] = _currentPartnumber) )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 , Thanks for yor quick reply.

Decided to use the advise from Greg, the LOOKUPVALUE function.

Will try your advise later.

have a good weekend, John

 

Greg_Deckler
Super User
Super User

You could create a bridge table. But, you could also use LOOKUPVALUE or MAXX(FILTER(...),...) @jwi1

@ 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...

@Greg_Deckler 

Hi Greg, tried LOOKUPVALUE and it worked fine!

Thanks

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.