Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
please help me.
my sumx function isnt working for a total qty measure i calculated.
I have my Qty measure where I am replacing my empty rows with the previous values as such
final Qty =
Solved! Go to Solution.
Hi @yve214
Please use
Final 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
Please use
Final 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
)
)
)
@tamerj1 Thank you so much again for your help. This worked like magic.. Amazing!
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 |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |