Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

DISTINCTCOUNT not working as expected

Hi everyone! I'm having this issue where I need to get a ranking of the most suspended orders by product. In order to achieve this, I have a "SUSPENDED_ORDERS" table, where one order_id equals one suspended order.

I tried to solve this issue, by using a DISTINCTCOUNT(SUSPENDED_ORDERS[order_id]) DAX function, but it's not counting properly.

I used a scorecard to show the result of the DAX function I created, and the result was 441 (this is the expected result).

 

I also used a table, where I brought the product description (SUSPENDED_ORDERS[order_id]) and my DISTINCTCOUNT function (DISTINCTCOUNT(SUSPENDED_ORDERS[order_id])), and the grand total was 441 (expected result), but it wasn't counting properly by product.

 

I exported the table above in a csv file, and the result of adding all the suspended orders was 919 (incorrect result).

 

I also exported all the products with their respective order_id's on another csv file, and did a count of all the order_id's, and the result was 919 as well, but once I removed the duplicates, the count decreased to 441.

 

 

So, apparently the DISTINCTCOUNT is working properly for the grand total and the scorecard as well, but when the product description is involved, it's only doing a COUNT insted.

 

I'm aware this is a common bug by the platform. I also used this solution I saw on another website, but got the same unexpected result:

 

# test_measure =
var sampletable1=
    SUMMARIZE(
        'SUSPENDED_ORDERS',
        'SUSPENDED_ORDERS'[PRODUCT_DESC],
        "DISTINCT_ORDERS", DISTINCTCOUNT(SUSPENDED_ORDERS[ORDER_ID])
    )
return SUMX(sampletable1, [DISTINCT_ORDERS])
 
Is there workaround for this problem?. Thanks a lot for your help.
 
Cheers!
 
Martin B.-

1 Reply

  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion

    Anonymous 

    When I have seen this with my example , it works properly! Share some sample data to understand theissue