Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello All,
I have the following table with the Cumulative Amounts split across Dates and Type and I want to calculate the amounts in between dates.
For Example: Between 6/27 and 7/25, the amount that was shipped was 35 (721-685) for Type=PF1. Also since 5/30 is the first date in the table, the cumulative amount = Desired Measure
How do I do this in DAX?
I tried using EARLIER but since the dates do not increment by 1 every time, I'm not getting the desired amount
=
VAR CumulativeAmountPreviousDate =
CALCULATE (
SUM ( 'Table'[CumulativeAmount] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date]
= EARLIER ( 'Table'[Date] ) - 1
&& 'Table'[Type] = EARLIER ( 'Table'[Type] )
)
)
RETURN
'Table'[CumulativeAmount] - CumulativeAmountPreviousDate
Solved! Go to Solution.
Hi,
This calculated column formula works
=Data[Cumulative amount]-LOOKUPVALUE(Data[Cumulative amount],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Type]=EARLIER(Data[Type])&&Data[Date]<EARLIER(Data[Date]))),Data[Type],Data[Type])
Hope this helps.
Hi,
This calculated column formula works
=Data[Cumulative amount]-LOOKUPVALUE(Data[Cumulative amount],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Type]=EARLIER(Data[Type])&&Data[Date]<EARLIER(Data[Date]))),Data[Type],Data[Type])
Hope this helps.
I tried your solution but I'm getting this error
Calculation error in column '[]: A table of multiple values was supplied where a single value was expected.
Well then you obviously have cases where the same Date and Type combination repeats. Share a representative dataset and show the expetced result.
You were absolutely right. I grouped them by data and type and your formula worked! Thanks a lot!
You are welcome.
User | Count |
---|---|
140 | |
113 | |
104 | |
76 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |