Forum Discussion
BartVlek
6 years agoHelper II
Problems with syntax in combination with Related
I am having problems with getting the syntax right for the following expression: CostPrice = IF ( (RELATED ( 'discount'[percentage] ) = 0, ( 'total'[PAMP] ), ( ( 'total'[AMOUNT] ) * ( RELATED...
v-alq-msft
6 years agoCommunity Support
Hi, BartVlek
In Power BI Desktop, I need to create a calculated column as below.
CostPrice =
IF(
RELATED(discount[percentage]) = 0,
total[PAMP],
total[Amount]*RELATED(discount[percentage])
)
While in Dax Studio, you need to use the following formula.
EVALUATE
ADDCOLUMNS(
total,
"CostPrice2",
IF(
RELATED(discount[percentage]) = 0,
total[PAMP],
total[Amount]*RELATED(discount[percentage])
)
)
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BartVlek
6 years agoHelper II
Thanks again. When I run the transformed script into PBI I get the following error-message:
The syntax for 'totaal' is incorrect. (DAX(IF( RELATED(korting[kortingspercentage]) = 0. totaal[PAMP], totaal[bedrag]*RELATED(korting[kortingspercentage])))).
This is the script I used:
KOSTPRIJS-CORR =
IF(
RELATED(korting[kortingspercentage]) = 0,
totaal[PAMP],
totaal[bedrag]*RELATED(korting[kortingspercentage])
)
Thanks again,
Bart