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
NBOnecall
Helper V
Helper V

Measure - Count Rows by two columns?

Hi,

 

I had a measure working that I was counting the days "out of stock".

 

CountDaysOOS2 = CALCULATE(COUNTROWS(FILTER('ns vwInventorySnapshot','ns vwInventorySnapshot'[DetereminedQuantity] =0 && 'ns vwInventorySnapshot'[Date] > ('ns vwInventorySnapshot'[ns vwFirstDateInStockByLocation.FirstDateInStock]) && 'ns vwInventorySnapshot'[Date] < if(ISBLANK('ns vwInventorySnapshot'[ns ValogixPlanning.PhaseOutDate]),"12/31/2099",'ns vwInventorySnapshot'[ns ValogixPlanning.PhaseOutDate]))))

So lets say this is what the table looks like, with the out of stock being what I would consider the CountDaysOOS2. For Internal ID 5 the first date that it was in Stock was 12/9, but on 12/10 we had 0 Quantity, this means we have been out of stock one day.

 

 OutOfStock.JPG

This measure worked before I put locations into the matrix, as before they were just grouped together. Now I get the same CountDaysOOS2 as they were when they are grouped. It doesn't appear that my measure is breaking out the item internal ID at each loctionID.

 

Capture.JPG

 

I am just lost in what to do or even understanding what is happening.

 

Thanks,

Noel

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @NBOnecall ,

 

You could add some filters in the calculate formula to show correct values. You could refer to the following DAX:

ALLEXCEPT('ns vwInventorySnapshot','ns vwInventorySnapshot'[Location])

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

I get the same results with the following measure. I am not sure I am using all expect correctly.

 

CountDaysOOS2.1 = CALCULATE(COUNTROWS(FILTER('ns vwInventorySnapshot','ns vwInventorySnapshot'[DetereminedQuantity] =0 && 'ns vwInventorySnapshot'[Date] > ('ns vwInventorySnapshot'[ns vwFirstDateInStockByLocation.FirstDateInStock]) && 'ns vwInventorySnapshot'[Date] < if(ISBLANK('ns vwInventorySnapshot'[ns ValogixPlanning.PhaseOutDate]),"12/31/2099",'ns vwInventorySnapshot'[ns ValogixPlanning.PhaseOutDate]))),ALLEXCEPT('ns vwInventorySnapshot','ns vwInventorySnapshot'[LocationId]))

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.