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
Anonymous
Not applicable

Measure using columns from two tables (not directly related)

Hello all,

newbie here.

It looks like I bit off more than I can chew.

I have three tables. Item - list of all possible components with their specifications. Stock_item - available amount of components and Product_item - lists of components needed for assembling different products. Item has one to many relation to both Stock_item and Product_item (one beeing on Item). Sample data below.

I need to calculate how many products of selected type I can manufacture from available components.

So I need to divide available amount by necessary amount for every component needed for selected product and get their minimum.

 

Sample data:

Item...
S4 - 001...
S4 - 002...
TX - 040...
TX - 030...
TX - 029...
TX - 053...
Z4 - 013...
TX - 044...
TX - 038...
TX - 042...
TX - 034...
TX - 033...
TX - 058...
TX - 084...
TX - 003...
TX - 076...
TX - 033...
TX - 058...
TX - 060...
D4 - 005...
D4 - 006...
D4 - 007...
TX - 048...
TX - 050...
TX - 051...

 

StockItemsAmount
S4 - 001450
S4 - 002500
TX - 040380
TX - 053360
Z4 - 013150
TX - 044100
TX - 038250
TX - 042360
TX - 033150
D4 - 005100
TX - 084250
TX - 076175
TX - 030320
TX - 058360
TX - 060150
D4 - 006100
D4 - 007250
TX - 048100
TX - 050250

 

ProductItemsAmountProduct
S4 - 0015A
S4 - 0023A
TX - 04015A
TX - 03011A
D4 - 0062A
D4 - 0078A
Z4 - 0138A
TX - 0444A
S4 - 0018B
TX - 0843B
TX - 04015B
TX - 03311B
TX - 0588B
TX - 0846B
TX - 0034B
TX - 07610C
TX - 0335C
TX - 0588C
TX - 0608C
D4 - 0054C
D4 - 0068C
D4 - 0075C
TX - 0483C
TX - 0507C
S4 - 0018C
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous Perhaps a column in your last table like the following. You could use the MIN by product to get the number of product that can be produced.

Column = 
  VAR __Item = 'Table3'[ProductItems]
  VAR __Amount = MAXX(FILTER('Table2',[StockItems] = __Item),[Amount])
RETURN
  DIVIDE(__Amount, [Amount])

 


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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Greg_Deckler Wow. Thank you. I'm not entirely sure what I'm doing yet, but it seems to work as it should.

Greg_Deckler
Super User
Super User

@Anonymous Perhaps a column in your last table like the following. You could use the MIN by product to get the number of product that can be produced.

Column = 
  VAR __Item = 'Table3'[ProductItems]
  VAR __Amount = MAXX(FILTER('Table2',[StockItems] = __Item),[Amount])
RETURN
  DIVIDE(__Amount, [Amount])

 


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

Top Solution Authors