Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Multiply two values based on conditions from multiple tables

Hello,

 

I have three tables:

 

Table 1 - Materials per product

 

ProductIDMaterialWeight
1Cotton50
2Polyester30
2Cotton10

 

Table 2 - Products

 

ProductIDFabricType
1Knitted
2Woven

 

Table 3 - Conversion factors

MaterialFabricTypeFactor
CottonKnitted0,5
CottonWoven0,4
PolyesterKnitted0,7

 

I want to do the following:

 

Per row in table 1 I want to multiply the weight with the correct conversion factor. The factor to be chosen depends on the material (table 1) and the fabric type (table 2). So f.i. for the first row in table one I would like to multiply 50 with 0,5 (cotton and knitted). In Excel I would make a composed value and use vlookup or in power query a composed value in both tables (f.i. cottonknitted and merge based on this). But since this example is a simplified version this will result in a lot of merging in the real scenario and slow the query down significantly. 

 

I feel like this should not be hard, but I'm rather new to DAX. Would like to get your input on how to solve this efficiently.

 

Thanks so much!

 

Regards,

 

T

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

In the MPP table, write these calculated column formulas

Fabric type = RELATED(Products[FabricType])
Factor = LOOKUPVALUE(CF[Factor],CF[FabricType],MPP[Fabric Type],CF[Material],MPP[Material])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish,

 

Thanks for your help!

 

If I do this, then it returns an #ERROR, stating "A table with multiple values was given while a singular value was expected" (translated). 

 

What should i do differently?

 

Thanks again.

Hi,

This error means that in the CF column, there are duplicats appearing in the Fabric type and/or Material columns.  Please share a representative dataset and on that one, show your expected result so that i can share the appropriate formula.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi, @Anonymous 

I don't see obvious problems in the formula, I doubt it's a problem with the data.

Please check the following points

1. Ids in 'Table 2'[ProductID] are unique

2. No invalid data rows (null values) in your original model

3. There is only one corresponding factor value for each material and fabric type in ‘Table 3’

 

Regards,

Ethan

lbendlin
Super User
Super User

Contrary to what you might think this is really hard.  You need to pull down the Fabric Type from the Product Dimension into the Materials per Product fact table, then create a composite key between Material and Fabric Type and then join the Materials per Product Table with the Conversion Factors table based on that key.

lbendlin_0-1659825638625.png

Once that is done you will notice that your conversion table is missing the factor for Woven Polyester.

 

lbendlin_1-1659825746662.png

Which factor should you assume in that case? 1 ?

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.