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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.