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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors