Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

DAX measure or Summarized table

Hello, 


I have data in the below format. I want to create a measure that will calculate the number of staff that have a rating that has only been completed by the manager. For example in the below it would total 2 as Person A has one (rating a) and Person C also has 1 (rating b).

 

If this is not possbible using measures, am I missing anything else before creating a new summarized table 

 

 

  • Got you. A bit funky but here you go:

    I created a concatenated column that would give me a Person + Rating so I could count that key. After that I created this measure that would give me the total occurrences of this key (I want everything that's just 1):

    CountAllS = CALCULATE(COUNT('Table'[PersonRating]), ALLEXCEPT('Table', 'Table'[PersonRating]))

    After this, I created a measure that counts the number of times this measure is just 1 and only for those that were rated by the manager:

    Unique Count = CALCULATE(COUNTROWS(FILTER(KEEPFILTERS(SUMMARIZECOLUMNS('Table'[PersonRating], "Count", [CountAllS])), [Count] < 2)), 'Table'[Rated by] = "Manager")

    Find attached my working file so you can take a dive on it 🙂 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    Your solution is great, ray_aramburo . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

     

    Just create a measure, the syntax is as follows:

    Count = CALCULATE(
         DISTINCTCOUNT('Table'[Person]),
         FILTER(
             'Table',
             'Table'[Rated by] = "Manager" &&
             CALCULATE(
                 COUNTROWS('Table'),
                 'Table'[Rated by] = "Self"
             ) = 0
         )
    )

     

    Drag measure to the report page for display:

     

    pbix file is attached.

     

    If you have any further questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

4 Replies

  • Why is Person C, rating a not included in your count?

    Anyways the measure can be done in 2 ways (depending to the answer of my first question) :

    Person Count = CALCULATE(COUNTROWS("TableName"), Rated by = "Manager")

    If you need to explicitly indicate "a" rating then just modify it this way:

    Person Count = CALCULATE(COUNTROWS("TableName"), Rated by = "Manager", Rating = "a")

    If you need to address unique person then just use DISTINCTCOUNT([Person]) instead of COUNTROWS.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, thank you for yor reply. Person C rating a is not included as they have [Rated by] entry for both "Manager" and "Self". I just need those that only have a [Rated by] "Manager". Hence I'm not sure the simple COUNT or DISTINCTCOUNT will work.

      • ray_aramburo's avatar
        ray_aramburo
        Super User

        Got you. A bit funky but here you go:

        I created a concatenated column that would give me a Person + Rating so I could count that key. After that I created this measure that would give me the total occurrences of this key (I want everything that's just 1):

        CountAllS = CALCULATE(COUNT('Table'[PersonRating]), ALLEXCEPT('Table', 'Table'[PersonRating]))

        After this, I created a measure that counts the number of times this measure is just 1 and only for those that were rated by the manager:

        Unique Count = CALCULATE(COUNTROWS(FILTER(KEEPFILTERS(SUMMARIZECOLUMNS('Table'[PersonRating], "Count", [CountAllS])), [Count] < 2)), 'Table'[Rated by] = "Manager")

        Find attached my working file so you can take a dive on it 🙂 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Your solution is great, ray_aramburo . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

     

    Just create a measure, the syntax is as follows:

    Count = CALCULATE(
         DISTINCTCOUNT('Table'[Person]),
         FILTER(
             'Table',
             'Table'[Rated by] = "Manager" &&
             CALCULATE(
                 COUNTROWS('Table'),
                 'Table'[Rated by] = "Self"
             ) = 0
         )
    )

     

    Drag measure to the report page for display:

     

    pbix file is attached.

     

    If you have any further questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!