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
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
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.

Top Solution Authors