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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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