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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
srpeters
Helper I
Helper I

Use Different Tables Data In a DAX Column

Hello,

 

I have three different tables with three different amounts. Two of these tables have different keys and the third table has both of these keys. I also have a fourth table with one of the keys and a description of what it correlates to. Here is some sample data:

Table 1:

PBIsh2.PNG

Table 2:

PBIsh4.PNG

Table 3:

PBIsh1.PNG

Table 4:

PBIsh3.PNG

As you can see I am getting an error message when trying to use DAX to subtract the three different tables amounts from each other in Table 3s DAX Column.

 

Below is the same DAX but as a measure:

PBIsh5.PNG

 

Is it possible to replicate this measure for each row as a column in a table rather than a measure?

 

Thank you in advance!

1 ACCEPTED SOLUTION

@srpeters Actually in looking at this closer, I believe the issue is that you are using RELATED to reference the same table that you are in, Table3. When creating a calculated column in Table3 that uses a column in Table3, just reference the column, [Column], you do not need to use RELATED and it actually won't work anyway and you will get the error you are receiving.


Follow on LinkedIn
@ 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

5 REPLIES 5
Greg_Deckler
Super User
Super User

@srpeters You can use MAXX(FILTER(...), ...) or LOOKUPVALUE to return data in other tables when no relationship exists.


Follow on LinkedIn
@ 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...

Since I do have a relationship between these tables through the keys, shouldnt RELATED work? 

 

My relationships:

PBIsh6.PNG

 

If not, then how would you format the LOOKUPVALUE for 3 different tables?

 

Thank you!

@srpeters Actually in looking at this closer, I believe the issue is that you are using RELATED to reference the same table that you are in, Table3. When creating a calculated column in Table3 that uses a column in Table3, just reference the column, [Column], you do not need to use RELATED and it actually won't work anyway and you will get the error you are receiving.


Follow on LinkedIn
@ 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...

I see now that the RELATED() function does not work for limited relationships. Since the data I am working with has many-to-many relationships, I guess I need to use LOOKUPVALUE or MAX(FILTER()). 

 

Thank you for your help!

@srpeters Right, RELATED works on the many side of a 1-to-many relationship. Might be able to use RELATEDTABLE along with an X-aggregator.


Follow on LinkedIn
@ 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors