Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Count across columns

Hi,

 

I have a data like the below (first 4 columns)

 

In PowerQuery M, I want to add a new column called 'Agent Count' with a count of the number of agents enabled per machine.

 

I have looked around this community. There is a solution to use groupby, which I don't want to use as I want to retain my original data.

 

Please help.

  • Hi Anonymous 

    simply add a column with this formula:

    List.Count(List.Select(Record.FieldValues(_), (x) => Text.Contains(x, "enabled")))

     

     

3 Replies

  • ImkeF's avatar
    ImkeF
    Community Champion

    Hi Anonymous 

    simply add a column with this formula:

    List.Count(List.Select(Record.FieldValues(_), (x) => Text.Contains(x, "enabled")))

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      That was much simpler than I thought. Thank you imkyu 

    • Anonymous's avatar
      Anonymous
      Not applicable

      This formulae does not seem to work in my case, which is very similar. I got all error values.