Forum Discussion
Sumx function isn't working for my view
- 4 years ago
Hi yve214
Please useFinal Qty = SUMX ( SUMMARIZE( Data, Data[Date], Data[Category] ), CALCULATE ( VAR CurrentDate = MAX ( Data[Date] ) VAR OriginalQty = SUM ( Data[Original Quantity] ) VAR CurrentCategoryTable = CALCULATETABLE ( Data, ALLEXCEPT ( Data, Data[Category] ) ) VAR PreviousDatesTable = FILTER ( CurrentCategoryTable, Data[Date] < CurrentDate ) VAR PreviousDate = MAXX ( PreviousDatesTable, Data[Date] ) VAR PreviousQty = CALCULATE ( SUM ( Data[Original Quantity] ), Data[Date] = PreviousDate ) RETURN IF ( ISBLANK ( OriginalQty ), PreviousQty, OriginalQty ) ) )
Hi yve214
what do you mean by
My apologies on the delayed response. PLease see SS below.
My total from this view, the final qty should be 70,609 but I am getting just 67,207. To have generated that final Qty, I used the measure listed above. I was calculating where if there is missing qty value for a date, take the qty for the previous day and subtitute.
For instance there is no quanty for category C for the date 5/28/2022, so my final Qty measure took the value from 5/27/2022 which is 3402 and filled in the gap. But this means, my final Qty now should be more than my original qty.
Here is the result data which seems to be working with the final Qty measure i calculated. BUt my sumx isnt working to give me my correct totals at the bottom.
| Date | Category | Original Quantity | Final Qty |
| 5/28/2022 0:00 | A | 2141 | 2141 |
| 5/28/2022 0:00 | B | 4227 | 4227 |
| 5/28/2022 0:00 | C | 3402 | |
| 5/27/2022 0:00 | A | 2143 | 2143 |
| 5/27/2022 0:00 | B | 4220 | 4220 |
| 5/27/2022 0:00 | C | 3402 | 3402 |
| 5/26/2022 0:00 | A | 2143 | 2143 |
| 5/26/2022 0:00 | B | 4364 | 4364 |
| 5/26/2022 0:00 | C | 3398 | 3398 |
| 5/25/2022 0:00 | A | 1998 | 1998 |
| 5/25/2022 0:00 | B | 4381 | 4381 |
| 5/25/2022 0:00 | C | 3781 | 3781 |
| 5/24/2022 0:00 | A | 1884 | 1884 |
| 5/24/2022 0:00 | B | 4532 | 4532 |
| 5/24/2022 0:00 | C | 3470 | 3470 |
| 5/23/2022 0:00 | A | 1912 | 1912 |
| 5/23/2022 0:00 | B | 4676 | 4676 |
| 5/23/2022 0:00 | C | 3786 | 3786 |
| 5/22/2022 0:00 | A | 2141 | 2141 |
| 5/22/2022 0:00 | B | 4733 | 4733 |
| 5/22/2022 0:00 | C | 3875 | 3875 |