Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cjl2144
New Member

Power Query - count columns with specific values

Is there a way to implement a "COUNTIF" Excel function in Power Query for a custom column? Preferably without having to write formulas to check the value of each column individually?

 

For example, for each row, I'd like a count of the number of columns that have a specific value (value = 6). See screenshot below from Excel, with the desired result in column J and formula in column K.

 

The only way I've found so far is to do something like this, but this becomes cumbersome if dealing with many columns (100+).

Any help is appreciated!

4 REPLIES 4
hnguy71
Super User
Super User

My suggestion is to begin by using UNPIVOT OTHER COLUMNS, then use GROUPBY, then do a COUNT for your specific value



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thanks for the suggestion. Where can you implement a COUNT for a specific value? All of the options I am able to find only do a count of the number of rows. 

 

PowerBIGroupBy.PNGPowerBIStatistics.PNG

It should already count for you.

 

Here's my example:

countif.png



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Select the Nodes columns >> Unpivot Columns >> Filter Values = 6 >> Group by Date and Node and count the rows.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.