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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JamieHornstein
Regular Visitor

DAX Help - calculated column multiple related tables

Hello all, I think what I want to do is possible, but I am not an expert in DAX.

 

I have 3 tables:Capture5.PNG

 I am trying to create a new column in the LocationList table called "Dynamic Capacity".  This should be the [Pallets Wide]*[Pallets Deep]*MAX([Item Master][Stacking Factor])).

 

I don't understand how to use DAX to traverse through two relationships to get to the item master.  LocationList is related to HJInventory by the WHLocation field and HJInventory to Item Master by ItemSite.

 

My current DAX expression is this:

Dynamic Capacity = LocationList[Pallets Deep]*LocationList[Pallets High]*CALCULATE(max(ItemMaster[stacking_factor]),ItemMaster[ItemSite]=RELATED(HJInventory[ItemSite]))

 

I get an error that says 'The column 'HJInventory[ItemSite]' either doesn't exist or doesn't have a relationship to any table available in the current context.'

 

Any ideas?

1 REPLY 1
JamieHornstein
Regular Visitor

I've been experimenting with USERELATIONSHIP and seem to have got closer.

 

On the LocationList Table, I have created a calculated column:

Dynamic Stacking Factor = CALCULATE(max(ItemMaster[stacking_factor]),USERELATIONSHIP(HJInventory[WHLocation],LocationList[WhLocation]),USERELATIONSHIP(ItemMaster[ItemSite],HJInventory[ItemSite]))

 

I am trying to nest the relationships, but it's not working.

 

So, I created two other calculated columns, one on LocationList table, and another on the HJInventoryTable:

Dynamic Stacking Factor2 = CALCULATE(max(HJInventory[Stacking Factor]),USERELATIONSHIP(LocationList[WhLocation],HJInventory[WHLocation]))

Stacking Factor = CALCULATE(max(ItemMaster[stacking_factor]),USERELATIONSHIP(HJInventory[ItemSite],ItemMaster[ItemSite]))

 

This returns the intended result, but when I try to use either of those in another calculated column on the LocationList table, I get a circular dependency error:

Dynamic Capacity = LocationList[Pallets Deep]*LocationList[Pallets Wide]*LocationList[Dynamic Stacking Factor2]

A circular dependency was detected: LocationList[Dynamic Stacking Factor2], LocationList[Dynamic Capacity],LocationList[Dynamic Stacking Factor 2].

 

This doesn't make sense to me, because [Dynamic Stacking Factor 2] doesn't appear to me to use the [Dynamic Capacity] function.

 

Help?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.