Forum Discussion

PBIuser2022's avatar
PBIuser2022
New Member
3 years ago
Solved

How to aggregate counts across multiple columns and rows

Hi all,

I have data that indicates how many warnings a user recieves when they perform a certain action. The data includes the last 30 instances each user performed the action and whether they recieved no warnings, one warning, or more than one warning from the system. I'd like to count how many times over all users and all instances each quantity of warnings appears.

My goal output is 3 custom columns which incate the count of each number of warnings in each row--I'd like to be able to plot these quantities in a pie or bar chart. I'm open to alternatives which would allow for the same or similar plotting.

 

Sampla Data:

Unique IDInstance 1Instance 2Instance 3Instance 4Instance 5Example "No Warnings" ColumnExample "One Warning" ColumnExample "Multi Warnings" Column

1

No warningsOne warningMultiple warningsNo warningsMultiple warnings212
2One warningOne warningNo warningsMultiple warningsOne warning131
  • PBIuser2022 

    Try something like this.  You would need one for each column.

    No Warning = 
    VAR _String = "No warnings"
    VAR _1 = 'Table'[Instance 1] = _String
    VAR _2 = 'Table'[Instance 2] = _String
    VAR _3 = 'Table'[Instance 3] = _String
    VAR _4 = 'Table'[Instance 4] = _String
    VAR _5 = 'Table'[Instance 5] = _String
    RETURN 
        _1 + _2 + _3 + _4 + _5

    Just change what it is looking for in _String

4 Replies

  • PBIuser2022 

    Try something like this.  You would need one for each column.

    No Warning = 
    VAR _String = "No warnings"
    VAR _1 = 'Table'[Instance 1] = _String
    VAR _2 = 'Table'[Instance 2] = _String
    VAR _3 = 'Table'[Instance 3] = _String
    VAR _4 = 'Table'[Instance 4] = _String
    VAR _5 = 'Table'[Instance 5] = _String
    RETURN 
        _1 + _2 + _3 + _4 + _5

    Just change what it is looking for in _String

    • PBIuser2022's avatar
      PBIuser2022
      New Member

      Makes sense.

      In Power Query I'm seeing a "Token EoF expected" popping up at the first line:

      = VAR _String = "No warnings"

      Additionally, "RETURN" is being corrected to "Type.FunctionReturn"

      • jdbuchanan71's avatar
        jdbuchanan71
        Icon for Super User rankSuper User

        This would not be done in powerquery.  It is just a calculated column done in DAX