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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
azaterol
Helper V
Helper V

Whats wrong in my DAX?

Hey all,

 

here is my calculated column.

 

accumulated Stock = 
calculate(
sumX('Goods logistics','Goods logistics'[Stock]),
FILTER(All('Goods logistics'),
And('Goods logistics'[Stock ID]=EARLIER('Goods logistics'[Stock ID]),
'Goods logistics'[Date]<=EARLIER('Goods logistics'[Date])
)))

 

 

It works fine until I have multiple outputs in a day. As an example, there are three outputs on August 13, 2022. The only correct thing here is the final score of -4. I wrote down the expected subtotals. Where is my misconception?

 

I calculated the 'stock' column in Power Query with 'Input' minus 'Output'.

stock.PNG

 

 

 

 

Here is the sample:

https://easyupload.io/qy59vb

 

Thank you for help.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@azaterol , try document number in place of date

 

accumulated Stock = 
calculate(
sumX('Goods logistics','Goods logistics'[Stock]),
FILTER(All('Goods logistics'),
And('Goods logistics'[Stock ID]=EARLIER('Goods logistics'[Stock ID]),
'Goods logistics'[Document No]<=EARLIER('Goods logistics'[Document No])
)))
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@azaterol , try document number in place of date

 

accumulated Stock = 
calculate(
sumX('Goods logistics','Goods logistics'[Stock]),
FILTER(All('Goods logistics'),
And('Goods logistics'[Stock ID]=EARLIER('Goods logistics'[Stock ID]),
'Goods logistics'[Document No]<=EARLIER('Goods logistics'[Document No])
)))
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  Doc Nr is fine, works great. With creating an index in power query I get more success! Anyways thank you.

@amitchandak  

 

not the expected output...

stock.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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