Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi, I have a Store Stock Qty measure that is in Store Stock table.
I want to create another measure that would be able to count number of rows in a table including dublicates.
I did try to create a measure but it is returning wrong results.
Expected result should be 4573 rows of 0.
If it is possible I would like a measure to be able count number of rows regardless if table is filtered to show 0 or not.
Thanks.
Click here to download the solution
How it works ...
Create a maeasue ..
Products out of stock at all warehouses =
VAR summarybyproduct =
ADDCOLUMNS(
VALUES(Inventory[Product]),
"Total stock",
CALCULATE(SUM(Inventory[Stock]))
)
VAR productswithzero =
FILTER(summarybyproduct,[Total stock] = 0)
RETURN
COUNTROWS(productswithzero)
See example ..
Product 6, 7 and 8 are out of stock at all warehouse. So the answer is 3 products.
Product 8 is out of stock in China and UK but has stock in German. Therefore it is has stock.
Thanks for the clear description of the problem with example data. I wish everyone did that!
Remember we are unpaid volunteers. So please click the thumbs up and the [accept as solution] button to leave kudos.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !
If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.
Please now click the thumbs up and the [accept as solution] button. Thnak you.
This part of the DAX does not work for me
CALCULATE(SUM(Inventory[Stock]))
)Since my stock is only accessible throu provided measure. There is no column that I can use.
Thanks
In that case try this ... and substitute [yourstockmeasure] with your own measure name
I have answered your question, so please be polite and click the thumbs up and accept solution buttons
It it does not work then it is problem with your measure ... but that is a different question
Products out of stock at all warehouses =
VAR summarybyproduct =
ADDCOLUMNS(
VALUES(Inventory[Product]),
"Total stock",
CALCULATE([yourstockmeasure])
)
VAR productswithzero =
FILTER(summarybyproduct,[Total stock] = 0)
RETURN
COUNTROWS(productswithzero)
@speedramps Hi, I got this error. I have no idea what it means since I am seeing it for the first time.
I have been lookign over your description of the solution again. And I think it is counting not what I am trying to count. Maybe my description of the problem confused you sorry if it did.
What I am trying to count is just total number of rows in the table. I attached this image maybe it will make it more clear.
Let me know if data sample would be helpfull.
The data that I have is using Live connection model so some of the actions are not available for me to use because of it.
Thanks
One part that I forgot to mention is that same product can exist in multiple stores at same time.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.