I’m hoping this is an easy answer. I’m dealing with an issue with a report that I am building that I
can’t seem to avoid a many-to-many relationship because of granularity.
I have one table that has an agreement number and a load number, and how much was in the load.
Then I have a cost table that has the corresponding agreement number in it (what I used for the relationship) a cost group and a cost amount.
I’m trying to get the total to calculate correctly.
I tried to provide a sample isolating the processing, but I deleted some of the sample data in the process, so It may not tie back to the original sample data set.
Not an easy answer, but where there’s a will, there’s often a way to get rid of the Many to Many. Here I created a table of unique agreement numbers that I used to filter both the Load and Cost tables. This should be done in Power Query, but I thought it was easier to illustrate the concept via DAX:
I brought in ‘Agreement’[Agreement], ‘Load’[Load] and ‘Load’[Volume], but when I brought in ‘Cost’[Cost Group] and/or ‘Cost’[Cost] I get the above error. I think because I don’t have the direct relationship between the two fact tables now.
Not sure what else I can try. Is there a way I can add columns to the ‘Load’ Table to add each Cost Group as a column? Or do a crossfilter or lookupvalue to add multiple cost groups to each contract and the cost associated with the group and contract? Thanks.
OK, I think we’re going to need to construct a full bridge table to get this all to work properly. It seems pretty clear to me that the combo of Agreement ID and Cost Group will produce a unique cost amount, correct? Is is also true that the combo of Agreement ID and Load will produce a unique volume amount?
The agreements table is my lookup table, This has a relationship with the Loads table and the Cost table at the Agreement ID level. The problem is the granularity of the Load table is the Load level, and the granularity of the Cost table is the cost group, so I don’t know how to tie them.
The costs for the cost groups are the same for each agreement and load.
I added an excel file to illustrate the calculation of the weighted average cost. The first problem is the table errors out in Power BI when I try to bring in the load and cost group because there is no relationship, and same with creating the calculations.
Just wanted to let you know that I haven’t forgotten about this. Just been consumed by prep for the upcoming Analytics Summit. Hope to have a solution for you on Friday 2/18. Sorry for the delay.
The bad news is that the DAX to get even a simple sum to work in the proper context is so complex as to be unworkable. Back to the drawing board – trying a different idea with a merged single fact table.
Hi @ibesmond, due to inactivity, a response on this post has been tagged as “Solution”. If you have any concern related to this topic, you can create a new thread.