Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago

DAX DISTINCTCOUNT FUNCTION

Good evening, I'm starting to use Power BI and would like your help in the following please:

I want to know the number of different codes but per request.

I used a formula but it results in the numbers of different codes in general:

N° LINES = DISTINCTCOUNT(BD_OUT[CODE]) which gives me a total of 4.
How would I make the result come out based on the order that would be the correct answer 5 (2 of the EP 5422372 and 3 of the order 54

N°PEDIDOCODE
5422372092091
5422372092092
5422373092091
5422373092237
5422373092238

I look forward to your help, thank you very much.

2 Replies

  • slakshmip07's avatar
    slakshmip07
    Frequent Visitor

    Hi, 

    If you want 5 in your card visual, you will have to use the below DAX:
    Measure= COUNT(BD_OUT[CODE])

    Using DISTINCTCOUNT will give you 4 as it counts the distinct values only, i.e, 92091,92092,92237, and  92238.

    If you want to see it as a 2 and 3 split, you will have to use a table visual and use the same measure.

     

    Below is what you will get,

    Hope this helps,
    Lakshmi

     

     

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Administrator

      Hello Lakshmi, good afternoon

      I have a problem using that formula, for example, in this order using the measure "Count" results in 8 items, but it is actually 7 since 1 is repeated. in this case how would you fix the formula?

      Thanks for the help

      Best regards