Reply
avatar user
Anonymous
Not applicable

Stock in and out

Hi all,

 

Another begginer question. I am working with products entering and leaving a facility, and I am trying to get the count of stock at any particular date.

 

I have a stock dimension with product ID, category, date of entry and the date of leaving, as such:

 

in and out 1.PNG

 

And I want to know the total count of each category at any given time. This is what the desired outcome would be (I've entered this manually):

 

 

In and out 2.PNG

I have already created a calendar table, so I only need to add the two columns with counts for A and B.

 

Hope it makes sense, and as always.

 

many thanks!

 

 

 

 

1 ACCEPTED SOLUTION
avatar user
Anonymous
Not applicable

I've found the solution, I leave the code I used for future reference:

 

Count A = CALCULATE(COUNTROWS('in and out'), FILTER('in and out','in and out'[Category]="A"),filter(ALL('in and out'),'in and out'[Date In] <= 'Calendar'[Date])) - CALCULATE(COUNTROWS('in and out'), FILTER('in and out','in and out'[Category]="A"),filter(all('in and out'),'in and out'[Date out] <= 'Calendar'[Date])) + CALCULATE(COUNTROWS('in and out'),FILTER('in and out','in and out'[Category]="A"), FILTER('in and out','in and out'[Active]))

View solution in original post

5 REPLIES 5
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may refer to the following posts.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
avatar user
Anonymous
Not applicable

@v-chuncz-msft ,

 

Thanks for your reply. Unfortunately that doesn't seem to work for me.

 

I am no expert in DAX, so maybe I am inputing the code incorrectly, however, even that measure would not provide me with the solution I need, which is a different count for each category, not just a total count.

 

Would really appreciate some help 🙂

avatar user
Anonymous
Not applicable

Any new ideas?

avatar user
Anonymous
Not applicable

I've found the solution, I leave the code I used for future reference:

 

Count A = CALCULATE(COUNTROWS('in and out'), FILTER('in and out','in and out'[Category]="A"),filter(ALL('in and out'),'in and out'[Date In] <= 'Calendar'[Date])) - CALCULATE(COUNTROWS('in and out'), FILTER('in and out','in and out'[Category]="A"),filter(all('in and out'),'in and out'[Date out] <= 'Calendar'[Date])) + CALCULATE(COUNTROWS('in and out'),FILTER('in and out','in and out'[Category]="A"), FILTER('in and out','in and out'[Active]))
avatar user
Anonymous
Not applicable

Any ideas?

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)