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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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