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
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
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.
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 🙂

Anonymous
Not applicable

Any new ideas?

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]))
Anonymous
Not applicable

Any ideas?

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.