Forum Discussion

EVEAdmin's avatar
EVEAdmin
Post Patron
6 years ago
Solved

Count Distinct Values By Column and by Date

Hi all

 

I have a table similar to the following

The table is already link to a DateTable

DBName is the name of the database providing the data

CustomerID is the ID of each customer in that database. 

As there are multiple databases, the customer ID can be repeated. Therefore, if an ID is listed in 2 different databases, it will actually identify 2 different customers.

 

I need to calculate the number of unique customers by year.

 

Hope I am clear, else I can provide more details, thank you.

  • Hi,

     

    Please find the below DAX measure solution.

    DistinctCountOfCustomer = CALCULATE(DISTINCTCOUNT(DB_Table[CustomerID]),VALUES(Date_Table[Year]))

    It is working fine. Please check and advise if it also works as per you.

     

     

     

     

    Thanks,

    Rakesh

  • If you need across the used combined column. If you need by DB and By year. Then you can take distinct of customer ID. But if you are using DBname in your visual then the combined one will also work.

6 Replies

  • Not sure I got it completely.

    There can be a few ways. But I will create a combined Column and then take distinct count

     

    New column = Table[DBName]& "-"&Table[CustomerID]

    Count Customer = calculate(distinctcount(Table[New column]))

  • Hi,

     

    Please find the below DAX measure solution.

    DistinctCountOfCustomer = CALCULATE(DISTINCTCOUNT(DB_Table[CustomerID]),VALUES(Date_Table[Year]))

    It is working fine. Please check and advise if it also works as per you.

     

     

     

     

    Thanks,

    Rakesh

    • EVEAdmin's avatar
      EVEAdmin
      Post Patron

      RakeshNag thank you.

      That returns unique customers by Year. I need unique customers by DBName by year 

      • amitchandak's avatar
        amitchandak
        Super User

        If you need across the used combined column. If you need by DB and By year. Then you can take distinct of customer ID. But if you are using DBname in your visual then the combined one will also work.