Forum Discussion
Finding value based on Column header and a column value and get respective Row Value
- 2 years ago
Hi Mani1404 ,
If Attr1Value, Attr2Value, Attr3Value, Attr4Value, Attr5Value cannot be used as hardcode, the outcome cannot be realized. That's the best DAX can do.
Numerator1 = VAR A = 'Order'[JoinConcatColumn] VAR B = CALCULATE( MAX('Cost'[Numerator]), FILTER( 'Cost', 'Cost'[JoinConcatColumn] = A ) ) RETURN B Denominator1 = VAR A = 'Order'[JoinConcatColumn] VAR B = CALCULATE( MAX('Cost'[Denominator]), FILTER( 'Cost', 'Cost'[JoinConcatColumn] = A ) ) RETURN BThe final output is like this:
If you are willing to use them as hardcode, it may be complex.
Please follow these steps:
1.Right-click Order, select New Column and input:
Numerator = SWITCH( LOOKUPVALUE(Cost[Numerator],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]), "Attr1Value",'Order'[Attr1Value], "Attr2Value",'Order'[Attr2Value], "Attr3Value",'Order'[Attr3Value], "Attr4Value",'Order'[Attr4Value], "Attr5Value",'Order'[Attr5Value])2.Right-click Order, select New Column and input:
Denominator = SWITCH( LOOKUPVALUE(Cost[Denominator],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]), "Attr1Value",'Order'[Attr1Value], "Attr2Value",'Order'[Attr2Value], "Attr3Value",'Order'[Attr3Value], "Attr4Value",'Order'[Attr4Value], "Attr5Value",'Order'[Attr5Value] )3.Right-click Order, select New Column and input:
Sum = SWITCH( LOOKUPVALUE(Cost[Sum],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]), "Attr1Value",'Order'[Attr1Value], "Attr2Value",'Order'[Attr2Value], "Attr3Value",'Order'[Attr3Value], "Attr4Value",'Order'[Attr4Value], "Attr5Value",'Order'[Attr5Value])Best Regards,
Caroline Mei
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Mani1404 ,
If Attr1Value, Attr2Value, Attr3Value, Attr4Value, Attr5Value cannot be used as hardcode, the outcome cannot be realized. That's the best DAX can do.
Numerator1 =
VAR A = 'Order'[JoinConcatColumn]
VAR B =
CALCULATE(
MAX('Cost'[Numerator]),
FILTER(
'Cost',
'Cost'[JoinConcatColumn] = A
)
)
RETURN
B
Denominator1 =
VAR A = 'Order'[JoinConcatColumn]
VAR B =
CALCULATE(
MAX('Cost'[Denominator]),
FILTER(
'Cost',
'Cost'[JoinConcatColumn] = A
)
)
RETURN
B
The final output is like this:
If you are willing to use them as hardcode, it may be complex.
Please follow these steps:
1.Right-click Order, select New Column and input:
Numerator =
SWITCH(
LOOKUPVALUE(Cost[Numerator],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]),
"Attr1Value",'Order'[Attr1Value],
"Attr2Value",'Order'[Attr2Value],
"Attr3Value",'Order'[Attr3Value],
"Attr4Value",'Order'[Attr4Value],
"Attr5Value",'Order'[Attr5Value])
2.Right-click Order, select New Column and input:
Denominator =
SWITCH(
LOOKUPVALUE(Cost[Denominator],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]),
"Attr1Value",'Order'[Attr1Value],
"Attr2Value",'Order'[Attr2Value],
"Attr3Value",'Order'[Attr3Value],
"Attr4Value",'Order'[Attr4Value],
"Attr5Value",'Order'[Attr5Value]
)
3.Right-click Order, select New Column and input:
Sum =
SWITCH(
LOOKUPVALUE(Cost[Sum],Cost[JoinConcatColumn],'Order'[JoinConcatColumn]),
"Attr1Value",'Order'[Attr1Value],
"Attr2Value",'Order'[Attr2Value],
"Attr3Value",'Order'[Attr3Value],
"Attr4Value",'Order'[Attr4Value],
"Attr5Value",'Order'[Attr5Value])
Best Regards,
Caroline Mei
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.