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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.