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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Countif for 50 country columns to show sum of each country

Hi, i'm a complete newbie to visualizations. I have 50 columns that I want do a countif on. In excel I can easily do this with a countif on all the columns (I already have a list of countries). I looked through a lot of solutions and unfortunately I don't seem to understand how to do this in Power BI. I am using Power BI Version 2.85.985.0 64-bit.

 

If someone can explain this to me like a 5 year old, I would really appreciate!

6 REPLIES 6
jthomson
Solution Sage
Solution Sage

Will be much, much easier if you clean the data up - unpivot all the columns so rather than having one row with 50 columns, you get 50 rows with two columns (one with the country, one with the value) - it's then a pretty simple countrows measure from there with whatever criteria you'd have been countifing on before

Anonymous
Not applicable

Hi jthomson, perhaps I didn't explain clear on my end. Here is what the data looks like (but for 50 columns):

 

HAA_1113_0-1602856866933.png

each row is a business entity. The original data set had one column with each cell as all countries separated by a semi colon. I had to split that into multiple columns to get an accurate count of each country. 

 

I guess there are two things I need to do: get a unique list of all the countries that appear in all these columns, and get a count of them.

Anonymous
Not applicable

Perhaps there is another way to organize this data. I could import a second table with list of countries and count of each country; However, I don't see how I could connect it back to my original data set. Open to all suggestions!

Hi @Anonymous ,

 

Is this not what you want?

 

v-lionel-msft_0-1603097802160.pngv-lionel-msft_1-1603097816574.png

v-lionel-msft_2-1603097936091.png

 

Best regards,
Lionel Chen

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

 

Anonymous
Not applicable

Not really, because each column can have any country. Each row looks like this (starting with header):

 

entity_name; country1; country2; country3; country4

 

entity_x; Brazil; China; India; (blank); 

entity_y;(blank);(blank);(blank); (blank);

entity_z; Canada; Mexico; (blank); (blank);

 

each column can hold any country. The reason it goes to 50 columns is because a few entities do business with 50 countries. Some only do business with one country. A lot are just blank. Hope that helps!

 

 

 

Hi @Anonymous ,

 

If you don't transform the table, you have to create 50 measures to count each column.
Or you can add all the columns to the table visual and use the aggregation feature that comes with the table visual.

 

Best regards,
Lionel Chen

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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