Forum Discussion
COUNTROWS returning wrong value
Hey,
I have another pbix in which I am trying to do a count, but it is not working.
On the original app the measure is like:
Prod. no Cons. (#) =
-- Number of Production orders without consumption
CALCULATE (
COUNTROWS (
SUMMARIZE (
--F_PRODUCTION_ORDER,
NATURALINNERJOIN(ALLSELECTED(F_PRODUCTION_ORDER),ALLSELECTED(LINKTABLE)),
Dim_PLANT[Plant Code],
F_PRODUCTION_ORDER[Production Order],
F_PRODUCTION_ORDER[Opening]
)
),
F_PRODUCTION_ORDER[FLAG_PROD_NO_CONS] = "Y"
)
This is not working because it is showing the total value of rows counted for every day, instead of showing only on the day in which the order exists.
Example below:
I have created and test application that represents the way my model is created with a similar measure.
The difference here is that in my original model the relationship between Linktable and Sales is many-to-many with a bridge table in the middle.
This link: https://we.tl/t-qH7rYEiMJ5
Can you help me understand what I am doing wrong with this measure to get the desired result. I expect it to show only on the day in which the order exists in Sales.
Prod. no Cons. (#) =
-- Number of Production orders without consumption
CALCULATE (
COUNTROWS (
SUMMARIZE (
--F_PRODUCTION_ORDER,
NATURALINNERJOIN(ALLSELECTED(Sales),ALLSELECTED(LINKTABLE)),
Plant[Plant],
Sales[Order],
Sales[Opening]
)
)
)
Thank you.
Best regards,
André
3 Replies
- amitchandakSuper User
afbraga66 , I changed the data model, created correct join, and changed measures.
Refer if the file attached can help
- afbraga66Helper III
Hey amitchandak, thanks for you answer.
Still, is it not possible to do with the model that I had? I don't understand what's the issue on it.
Thanks.
- afbraga66Helper III
amitchandakSorry, but can you help understand why the model I had doesn't work? And how to make it work in that model? Thank you.