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
mikeborg82
Helper II
Helper II

DAX help

I am trying to create a new measure based on two other columns.  I want to create a column that tells me the average increase of salaries... I have both before and after.  When I create the DAX column I cannot seem to get any fields from that table into the formula.  I have tried closing, refreshing, etc... Any ideas of what I can do. This is the first time Ive had this happen.

 

Thanks.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Try using RELATED or RELATEDTABLE


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hi @mikeborg82,

Remarks
The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship.

When the RELATED function performs a lookup, it examines all values in the specified table regardless of any filters that may have been applied.

System_CAPS_ICON_note.jpg Note


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.



For more details about RELATED and RELATEDTABLE function, you can refer to the following two articles. Smiley Happy

https://msdn.microsoft.com/en-us/library/ee634202.aspx

https://msdn.microsoft.com/en-us/library/ee634226.aspx

 

Regards

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Try using RELATED or RELATEDTABLE


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

That works.  Thanks for your help.  Can you explain what it was doing?  I am pretty new to powerbi.

 

 

Hi @mikeborg82,

Remarks
The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship.

When the RELATED function performs a lookup, it examines all values in the specified table regardless of any filters that may have been applied.

System_CAPS_ICON_note.jpg Note


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.



For more details about RELATED and RELATEDTABLE function, you can refer to the following two articles. Smiley Happy

https://msdn.microsoft.com/en-us/library/ee634202.aspx

https://msdn.microsoft.com/en-us/library/ee634226.aspx

 

Regards

Typically when creating DAX custom column is that the context is constrained to the table that you are in. To change context, one can use things like RELATED and RELATEDTABLE to change the context in which the DAX operates.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.