Hi Sam/all,
I’m pretty confuse on how to use DAX Average function, although I did look at your Youtube about Average per transaction. Been reading and try to digest the reading material from SQLBI about context transition, but I still not getting what I want.
The thing is, I have a transaction data, which has some duplicate value which causing the amount to be doubled. The data is something like this :
SalesID | SalesTeritory | OrderDate | Price | Qty | Location |
---|---|---|---|---|---|
SO-01 | EAST | 1/1/2019 | 500 | 1 | Main W/H |
SO-02 | EAST | 1/1/2019 | 100 | 1 | Main W/H |
SO-03 | WEST | 1/9/2019 | 200 | 2 | Main W/H |
SO-03 | WEST | 1/9/2019 | 200 | 2 | Aisle 2 |
SO-04 | WEST | 1/3/2019 | 300 | 4 | Main W/H |
SO-05 | WEST | 2/1/2019 | 100 | 7 | Main W/H |
In above table, SO-03 is doubled . This is because the location is actually from other table and after join table, that is the result.
So I think, I just create a measure and average the amount, that would solve the problem. It turned out it’s not that easy.
At first I have a simple measure for the total :
[Total Amount] = SUMX(
Sales,
Sales[Price] * Sales[Qty])
After I have duplicate rows, I think I can create this measure :
[AVG Total Amount] = AVERAGEX(
VALUES(Sales[SalesId]),
[Total Amount]
)
However when I put in Table visual, just display the Sales Id and that Measure, I saw the amount is doubled.
There is some resources suggesting to put CALCULATE in that [Total Amount], but the result is the same.
Can you help me to understand more about this issue ?
Many thanks in advance.