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.
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.
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 |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
138 | |
107 | |
104 | |
82 | |
63 |