Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Distinctcount GroupBy?

Hi,      I have a table lets call it Facts it has the following coulmns:    ProjectName         Dep        WorkerCode X1                         Sales           89 X1                         S...
  • Anonymous's avatar
    Anonymous
    7 years ago

    or if you want the DAX version:

    Table = 
    ADDCOLUMNS(
        SUMMARIZECOLUMNS( 
            'Fact'[ProjectName ], 
            'Fact'[Dep      ]
        ),
        "Distinct Count", 
        CALCULATE(
            DISTINCTCOUNT('Fact'[WorkerCode])
        )
    )
    
    

  • MarkLaf's avatar
    7 years ago

    I'll quickly note that if you're goal is to simply have a visual that shows this info in a report/dashboard, then you don't need to write any DAX.

     

    Simply create a table visual, add in ProjectName, Dep, and WorkerCode, then hit dropdown on WorkerCode value and change aggregation setting to "Count (Distinct)" – you can change display name of the columns in the same dropdown menu, too (if for example you don't like "Count of WorkerCode").