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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a data set which shows available units by product and day. I would like to add a column which calculates the change in available units for each product from the previous day. What formula would I used to create this column?
Solved! Go to Solution.
You can do it like this:
Difference With Yesterday =
SUMX (
SUMMARIZE ( Data, Data[SKU], Data[Day] ),
VAR ThisDay = Data[Day]
VAR YestAmount =
CALCULATE ( SUM ( Data[Available Count] ), Data[Day] = ThisDay - 1 )
RETURN
IF (
ISBLANK ( YestAmount ),
BLANK (),
YestAmount - CALCULATE ( SUM ( Data[Available Count] ) )
)
)
You cannot use the time intelligence PREVIOUSDAY function because you do not have a Date table
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Do you have seperate record for each item for each day? could you please post sample data ( in copy- pastable format) with expected output?
Thanks
Raj
Day SKU Available count Daily Change
9/15/2018 111111 20
9/15/2018 111112 17
9/15/2018 111113 14
9/16/2018 111111 18 2
9/16/2018 111112 16 1
9/16/2018 111113 14 0
9/17/2018 111111 13 5
9/17/2018 111112 13 3
9/17/2018 111113 12 2
The last column is what I am trying to create.
You can do it like this if you want to add a calculated column, even though a measure would be better
Column =
VAR PrevVal =
CALCULATE (
SUM ( Data[Available Count] ),
ALLEXCEPT (
Data,
Data[SKU]
),
Data[Day] = EARLIER ( Data[Day] ) - 1
)
RETURN
IF (
ISBLANK ( PrevVal ),
BLANK (),
PrevVal - Data[Available Count]
)
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
What would be the measure formula?
You can do it like this:
Difference With Yesterday =
SUMX (
SUMMARIZE ( Data, Data[SKU], Data[Day] ),
VAR ThisDay = Data[Day]
VAR YestAmount =
CALCULATE ( SUM ( Data[Available Count] ), Data[Day] = ThisDay - 1 )
RETURN
IF (
ISBLANK ( YestAmount ),
BLANK (),
YestAmount - CALCULATE ( SUM ( Data[Available Count] ) )
)
)
You cannot use the time intelligence PREVIOUSDAY function because you do not have a Date table
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Have a look at the PREVIOUSDAY function
https://msdn.microsoft.com/en-us/query-bi/dax/previousday-function-dax?f=255&MSPPError=-2147217396
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |