Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Petanek333
Helper III
Helper III

Calculate changes between dates for various data categories

Hi, 

I have a table like this.

Petanek333_0-1660921510201.png

and a date slicer 'Calendar'[Dates] 

Petanek333_1-1660921712115.png

 

There is data about stock movement in the table StockTable.

Column "Type" is for distinguishing between increase (1) and decrease (2) of stock.

I have several IDs and Warehouses (those are two data categories I want to analyze).

Column "Quantity" represents the amount of stock that has increased or decreased. 

Finally column "Current stock" represents the value of stock after the change.

 

I am struggling with the DAX expressions for the following views: (I suppose more than one DAX formula will be necessary)

With this slicer selection...

Petanek333_4-1660923096964.png

...I want to see this (obviously the the column names don't have to include the selected dates)

Petanek333_3-1660922810162.png

There are some key points: 

- the formula has to find the nearest earlier date in order to get a stock value for that date (for both starting and ending date)

- it has to distinguish between decrease and increase by the "Type" column as there are absolute values (or should I use the calculated column instead?)

 

...and of course the same for the Warehouse as there are several ID-Warehouse combinations.

 

Can you help me with the DAX expression please?

2 REPLIES 2
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @Petanek333 - I would like to suggest simplifying the DAX by changing the way you import the data.  This would involve removing the "Type" (increase / decrease) and changing the Quantity to +/-.  Now the DAX would simply add the quantity movements between the required dates.

Hi @Daryl-Lynch-Bzy  and thank you for your suggestion. I will do it. Will be still struggling with the DAX though 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.