Forum Discussion

afbraga66's avatar
afbraga66
Helper III
3 years ago

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