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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
FlappyRabbit
Frequent Visitor

CountRows help

I have a table with US states in Column A and then 10 columns headed with different animals. I have a "y" in the table if that animal is found in that state, how do I create a new column/measure to count how many "y"'s for each state (row) please??

1 ACCEPTED SOLUTION

Thanks, I get erros when I enter the code (likely my error as totally new to DAX/coding...). I used a COUNTIFS formula in the Excel source file instead in the end which achieved the same goal.

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

That's fine. If you have skills in Excel that's the place to solve an issue.

HotChilli
Super User
Super User

In Power Query, you could add a column using List.Select(, for example,

List.Select({[Column1],[Column2],[Column3]}, each _ = "y"))

and you can wrap that with a List.Count to count the "y"'s

----

However, the most flexible solution would probably be to Unpivot all the Animal columns (in Power Query) and write a single DAX measure using COUNT.

Thanks, I get erros when I enter the code (likely my error as totally new to DAX/coding...). I used a COUNTIFS formula in the Excel source file instead in the end which achieved the same goal.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors