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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.