Forum Discussion
Dax Help- Average or divide by Row
- Anonymous1 year ago
Hi red75116,
Thanks for the clarification. You are right that "AVERAGEX(VALUES(...))" ends up averaging across distinct IDs, which can lead to unexpected results if your visual still includes multiple duplicate rows. In your case, since the same ID (like 113) appears multiple times due to the join, we need a DAX measure that returns the original amount per ID, and consistently displays it across all duplicate rows.
Try this measure once:
Correct Amount :=
CALCULATE(
MAX(MergedTable[Amount]),
ALLEXCEPT(MergedTable, MergedTable[ID])
)This "MAX(MergedTable[Amount])" will get the original amount per ID (assuming the value is consistent) and "ALLEXCEPT(...)" removes any filters except for ID, so that even if the same ID appears multiple times in the visual, you’ll get the same value for each row.
This should return 14 for all rows with ID 113, 10 for all rows with ID 114 and 20 for ID 115.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
I was able to get the right results by creating a merged table and grouping on these values, but it would better I think if i could work this out with a measure.
Your solution is providing the average amounts for all the ID records. Instead of getting a valuue of 44, I am getting
44/3 = 14.66
ID | Title | Amount
113 | Red | 14
113 | Red | 14
113 | Red | 14
114 | Red | 10
114 | Red | 10
114 | Red | 10
115 | Red | 20
I would want to see 1 value or the average from the ID. Should be 44 and it is giving me the total / by all red rows (7) 13.14.