Forum Discussion
Anonymous
4 years agoNot applicable
Divide specific ratio if value starts with
I have two tables showing the value of items and ratio to be divided. How to create a new table showing the divided values by the product code? Table 1: Table 2: Expected table ...
- Anonymous4 years ago
Hi Anonymous ,
you can create a calculated column using the following DAXNew Value(value/ratio) = DIVIDE( 'Table 1'[Value], LOOKUPVALUE( 'Table 2'[Ratio], 'Table 2'[Product Code], LEFT('Table 1'[Item],2) ) )Regards
- 4 years ago
Anonymous ,
Step 1: First create the relationship between this 2 tables by creating Product Code calculated column in Ratio table,
Product Code = LEFT(Ratio[Item],2)Step 2: Then create the relationship between them as per the below image,
Step 3: Lastly you can create the new table by using the below code,
New Value Table = SELECTCOLUMNS(Ratio,"Item",Ratio[Item],"New Value",DIVIDE(Ratio[Value],RELATED('Product deatails ratio'[Ratio])))Thanks,
Arul
- Anonymous4 years ago
If you want the result in a new table, you can use
Table 3 = SELECTCOLUMNS( 'Table 1', "Item",'Table 1'[Item], "New Value(value/ratio)", DIVIDE( 'Table 1'[Value], LOOKUPVALUE( 'Table 2'[Ratio], 'Table 2'[Product Code], LEFT('Table 1'[Item],2) ) ) )Regards
- 4 years ago
Hi Anonymous
Assuming relationship is useless in this case and that you are looking for a calculated column then you can try
New Value = VAR CurrentValue = Table1[Value] VAR Ratio = CALCULATE ( VALUES ( Table2[Ratio] ), FILTER ( Table2, CONTAINSSTRING ( Table1[Item], Table2[Product code] ) ) ) RETURN DIVIDE ( CurrentValue, Ratio )
Anonymous
4 years agoNot applicable
Hi Anonymous ,
you can create a calculated column using the following DAX
New Value(value/ratio) =
DIVIDE(
'Table 1'[Value],
LOOKUPVALUE(
'Table 2'[Ratio],
'Table 2'[Product Code],
LEFT('Table 1'[Item],2)
)
)
Regards
- Anonymous4 years agoNot applicable
If you want the result in a new table, you can use
Table 3 = SELECTCOLUMNS( 'Table 1', "Item",'Table 1'[Item], "New Value(value/ratio)", DIVIDE( 'Table 1'[Value], LOOKUPVALUE( 'Table 2'[Ratio], 'Table 2'[Product Code], LEFT('Table 1'[Item],2) ) ) )Regards