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
KristofferAJ
Helper III
Helper III

Calculated column taking a count fixed to a country column

I would like to make a column or measure which takes my country column and return a number of houses in a certain colour.

 

For instance I have 23 yellow houses in my dataset in US and 14 yellow houses in Poland

 

A: Country column (e.g. Poland, United States)

B: Colour of house (e.g. Red, Yellow)

 

My wish i to get this out:

 

COUNTRY (Count of yellow houses)

United States (23)

Poland (14)

 

In tableau I would use a count and a FIX logic, i wonder if powerBI is able to make counts fixed to a specific country i a column

 

 

 

 

7 REPLIES 7
jaideepnema
Solution Sage
Solution Sage

@KristofferAJ ,

If i understood correctly have you tried creating a table or any visual and apply a visual level filter of color=yellow ?

 

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

Fowmy
Super User
Super User

@KristofferAJ 

Insert a table visual and add the country field, then create a new measure as follows and addit:

 

No of Houses = COUNTA ( TABLE[Colour of house])



If you need explicit measures to use in a card visual then create two different measures:

No of Houses  USA = CALCULATE ( COUNTA ( TABLE[Colour of house]) , TABLE[Country] = "United States" )

No of Houses  Poland = CALCULATE ( COUNTA ( TABLE[Colour of house]) , TABLE[Country] = "Poland" )

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank for your quick response, however I need this in one column only:

Poland (14)
United States (23)

so the fomula needs to takes the country in from the country column A, and then count all the houses with Yellow from column B

 

@KristofferAJ 

Try this one please:

No of Houses  USA = CALCULATE ( COUNTA ( TABLE[Colour of house]) , TABLE[Country] = "United States" , TABLE[Colour of house] = "Yellow" )

No of Houses  Poland = CALCULATE ( COUNTA ( TABLE[Colour of house]) , TABLE[Country] = "Poland", TABLE[Colour of house] = "Yellow"  )


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thanks, but I have 43 countries, and new coming in, so I would need a formula which picks it up from the country column and not by find "United States"

@KristofferAJ 

If you need it to be dynamics then use the following measure in a matrix, you will have Country in Column and Color in Row section and the measure in the value section, the calculation will work correctly following the filter context at each intersection of country and color.

No of Houses = COUNTA ( TABLE[Colour of house])

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi again, 

Still trying to get this to work.. 

 

One piece is clear (being the counts) - however I can get it to work when combining it with the name of the country.

 

Issue is that the numbers will change depending on filters and data input

 

For the count i used a measure, and for the country (Repsonses) i used a column

 

KristofferAJ_0-1631083799467.png

 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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