Forum Discussion

skiely's avatar
skiely
Frequent Visitor
9 years ago
Solved

Problem With Countrows Function

I'm strugling with DAX, I have been trying to create a New Column that counts the number of times a User in my database has a certain Role.   I have been using unsucessfully trying CALCULATE(COUNTR...
  • SqlJason's avatar
    SqlJason
    9 years ago

    I just used your formula in a measure (and not a calculated column), and then used it on our sample data. It seems to give the right results.

    cntrows = CALCULATE(COUNTROWS(Table1), FILTER(Table1, Table1[Role]="Primary")) & " P  " &  CALCULATE(COUNTROWS(Table1), FILTER(Table1, Table1[Role]="Backup")) & " B"

     

    It would be easier for us to help you if you give sample data (like you gave), and then show exactly what the results should be with the sample data. Feel free to change the sample data but make sure that you show what the end results also need to be, so that we can replicate it in Power BI