cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anurag_sethi Frequent Visitor
Frequent Visitor

Count across columns

Hi,

 

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

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Re: Count across columns

Hi @anurag_sethi 

simply add a column with this formula:

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

 

 

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark my post as a solution. Thanks!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

2 REPLIES 2
Super User III
Super User III

Re: Count across columns

Hi @anurag_sethi 

simply add a column with this formula:

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

 

 

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark my post as a solution. Thanks!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

anurag_sethi Frequent Visitor
Frequent Visitor

Re: Count across columns

That was much simpler than I thought. Thank you @imkyu 

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors