cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
srlabhe
Helper I
Helper I

Creating Measure DAX

Hi All,

I have below calculated column created 

$COGS = if(related('GL Account Dim'[ACCOUNT_GROUP])="INVOICED_PRICE" && 'Gross Profit Details'[PROFIT_CENTER]="19003",'Gross Profit Details'[AMOUNT]*0.681,
if(related('GL Account Dim'[ACCOUNT_GROUP])="COGS - SAP",'Gross Profit Details'[AMOUNT],0))
 
Need to convert into Measure DAX, but when I try to use IF or Switch it doesnt allow me to use Related,
Help appreciated
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @srlabhe ,

The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value.

Please adjust your dax formula.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @srlabhe ,

The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value.

Please adjust your dax formula.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors