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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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