Forum Discussion
Weighted Average on Narrow Table Using DAX Measure
- Anonymous2 years ago
Hi WishAskedSooner ,
First of all, many thanks to lbendlin for your very quick and effective replies.
Based on my testing, please try the following methods:
1.Create the simple table.
2.Create the new measure to calculate sum across all entry id.
Weighted Average = DIVIDE( SUMX( FILTER( 'Fact Table', RELATED('Dim Table'[Category]) = "A" ), 'Fact Table'[Value] * LOOKUPVALUE('Fact Table'[Value], 'Fact Table'[EntryID],'Fact Table'[EntryID], 'Dim Table'[Category], "B") ), CALCULATE(SUM('Fact Table'[Value]), ALL('Dim Table'), 'Dim Table'[Category] = "B") )3.Select the measure and edit the number of shown for the value.
4.Drag the measure into the card visual. The result is shown below.
You can also view the following links to learn about DAX function.
LOOKUPVALUE function (DAX) - DAX | Microsoft Learn
SUMX function (DAX) - DAX | Microsoft Learn
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It was suggested I provide sample data that fully covers my issue. So I will try to do that. I have the following three tables:
Fact
DimE joined on EID
DimA joined on AID
The following Data Model
I am trying to find a way to multiply the values for Category A and Category B (not Category C) in the Fact table by EID then sum the individual results.
For example, for EID 1, I want to multiply AID 1 and AID 2 together because they both belong to EID 1. Furthermore, I want to be able to specify this using the joined Category in DimA, i.e. for EID 1 multiply Category A by Category B. Then, for EID 2, multiply Category A and Category B. Repeat for each EID in the Fact table. Then sum the individual results. So,
(5*15 + 10*20) = 275
I would provide examples of what I have tried, but it is pointless because none come even close. I literally have no idea how to do this. Please help.