Forum Discussion

red75116's avatar
red75116
New Member
1 year ago
Solved

Dax Help- Average or divide by Row

I have a merged query that has a one to many (Left Join) relationship.   Data looks like   ID     |     Title    |   Amount 113   | Red         |  14 113   | Red         |  14 113   | Red     ...
  • Anonymous's avatar
    Anonymous
    1 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