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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
CarlosGonzalezC
New Member

Count columns if they fit with any condition ( countif )

Hi dear Community,

In Power BI (Desktop)

I have 20 columns with numbers and and I need to count them if they match with a value (i.e. count if the column's value = 0) 

 I need to create a new column with this count

Any advice how I can calculate it, since the countif function (for columns) does not exist in Power Bi

 

I appreciate your help

Carlos G.

 

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@CarlosGonzalezC 

 

With Query Editor, We can add a custom Column like

 

List.Count(List.Select(Record.ToList(_),each _ =0))

Thanks a lot for your help..

It worked, but I would like to understand it better.

Could you try to explain it in a few words?...pleaseee... I appreciate it

 

Thanks a lot

Carlos G.

 

Hi Zubair, 

Actually, I would like to know how I can specify a contigous range of columns in order to apply this "count if"...

How I can do it?

Below the 3 columns that I need to apply this "Count If"

 
 

screenShot.PNG

HI @CarlosGonzalezC 

You could use IF Functions in Power Query Including Nested IF for these three columns

https://www.computergaga.com/blog/if-functions-in-power-query-including-nested-ifs/

For example:

if [Column1]" and [Column2] and [Column3] then <Your expected outrput> else <Your other output>

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.