Forum Discussion

Tito's avatar
Tito
Icon for Helper IV rankHelper IV
2 years ago
Solved

DISTINCTCOUNT DAX

Hello everyone,

I have calculated the number of clients using the "DISTINCTCOUNT" function. Now I need a slicer so that I can filter according to the number of clients, i.e. the number less than or equal to 2 or greater than 2. For example: if the number of clients is less than or equal to 2, it should return "1", otherwise "0".

 

Thanks

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Tito ,

     

    I made simple samples and you can check the results below:

     

    Measure = var _COUNT = CALCULATE(DISTINCTCOUNT('Table'[Clients]),ALLEXCEPT('Table','Table'[Name]))
    RETURN IF(_COUNT<=2,1,0)

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

8 Replies

  • Hi Tito 

     

    I'm not following what you wanrt really - how does it realte to the image you posted?

     

    If you want a slicer, you'll need to create a table with the values you want the slicer to use.

     

    Please supply our data/fiel so I can see what it is you are doing.

     

    Regards

     

    Phil

    • Tito's avatar
      Tito
      Icon for Helper IV rankHelper IV

      Hallo PhilipTreacy 

      Vielen Dank für Ihre Antwort.

      Ich möchte einen Datenschnitt erstellen, damit ich nach der Anzahl der Kunden filtern kann, also möchte ich in einer Tabelle sehen, wie viele kleiner oder gleich 2 und wie viele größer als 2 sind.

      Mit freundlichen Grüßen
      Tito

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Tito ,

     

    I made simple samples and you can check the results below:

     

    Measure = var _COUNT = CALCULATE(DISTINCTCOUNT('Table'[Clients]),ALLEXCEPT('Table','Table'[Name]))
    RETURN IF(_COUNT<=2,1,0)

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

    • Tito's avatar
      Tito
      Icon for Helper IV rankHelper IV

      Hi Anonymous ,
      Thank you for your reply. This has helped me. Instead of "Measure" I have used a "calculated column".

       

  • Hello everyone,

    I have calculated the number of clients with DAX using the function "DISTINCTCOUNT". Now I want to have a slicer where I create a new measure: if the number of clients is < = 2, it should return "less than or equal to 2", otherwise " greater than 2".

    Thanks
    Tito

     

     

    • TomMartens's avatar
      TomMartens
      Icon for Super User rankSuper User

      Hey Tito ,

       

      unfortunately, it's not possible to use measures in combination with a slicer. This means you have to chck if you can meet your requirement using only calculated columns.

      But then you have to be aware of the fact that calculated that calculated columns will only be evaluated during data refresh and not when slicer selections are changed by users.

       

      Hopefully this helps to tackle your challenge.

       

      Regards,

      Tom

      • Tito's avatar
        Tito
        Icon for Helper IV rankHelper IV

        Hi TomMartens 
        Do you have any suggestions on how I can solve this?

        Best regards
        Tito