Forum Discussion

snph1777's avatar
snph1777
Icon for Helper V rankHelper V
1 year ago
Solved

DAX - measure filtered by another measure with SUMMARECOLUMNS - equivalent of T-SQL GROUP, HAVING,..

I have the below scenario: I have a table called EmployeeTable; it has 16 distinct employees, but each employee can have more than one row, based on the number of jobs she has had ; say, Geor...
  • snph1777's avatar
    snph1777
    1 year ago

    @lbendlin

     

    Thanks for your idea; I believe I got this; only thing, you did not include the Job in your formula; in my actual project, I have duplicate of employee names and jobs; so it is essential I use DISTINCTCOUNT function for any type of count.

     

     

     

     

     

     

     

    Active Multi Job1_Measure
    
    =
    
    VAR x_CT = SUMMARIZECOLUMNS(
    
                                 EmployeeTable[EmployeeId],
    
                                 TREATAS({"Y"},EmployeeTable[IsActiveEmployee]),
    
                                 "DistinctCountOfJobs_Measure",DISTINCTCOUNT(EmployeeTable[Job])
    
                                )
    
    RETURN
    
    COUNTROWS(
    
               FILTER(
    
                       x_CT,
    
                       [DistinctCountOfJobs_Measure] > 1
    
                     )
    
              )

     

     

     

     

     

     

    Can you validate the above code, whether it is fool-proof ? I tried this new measure in the Power BI file, it is good. Your idea to use SUMMARIZECOLUMNS proved very useful; I used the syntax from here.