Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi,
I am looking to calculate the difference in the "Numberofoutstandingitems" column between the latest date and the one before it. This is updated bi-weekly so it would need to also calculate based on the latest date and the one before it.
Thanks in advance for you help with this.
Solved! Go to Solution.
Hi @Whoule
is column ID coming from the data source. It could be a good helper column to identify which transaction comes first before the others.
Try this:
VAR PreviousValue =
CALCULATE (
SUM ( Data[Value] ),
Data[Date] = EARLIER ( Data[ID] ) - 1,
ALLEXCEPT ( Data, Data[Category] )
) // ALLEXCEPT to get the value before the current date per category
RETURN
Data[Value] - PreviousValue
Hi @Whoule
You can use EARLIER to access the data from a row other than the current one. Sample formula as per your use case
Difference =
VAR PreviousValue =
CALCULATE (
SUM ( Data[Value] ),
Data[Date] < EARLIER ( Data[Date] ),
ALLEXCEPT ( Data, Data[Category] )
) // ALLEXCEPT to get the value before the current date per category
RETURN
Data[Value] - PreviousValue
Hi Danextian,
The code is working but Var PreviousValue is making the sum of every value past the latest one which is not what I would like to do. I would like it to be only the past value so Latest value - previous value.
Hi @Whoule
is column ID coming from the data source. It could be a good helper column to identify which transaction comes first before the others.
Try this:
VAR PreviousValue =
CALCULATE (
SUM ( Data[Value] ),
Data[Date] = EARLIER ( Data[ID] ) - 1,
ALLEXCEPT ( Data, Data[Category] )
) // ALLEXCEPT to get the value before the current date per category
RETURN
Data[Value] - PreviousValue