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
sorathecat
Frequent Visitor

Visualization to show Country only

Hi Everyone, I have a data set currently that has columns of information containing city and country. For example: 

Location.PNG

When i create a visualization it will show as:

Location 2.PNG

 

Is there anyway that i can group everything into countries? Currently there is multiple different bars because of different cities. I want to only show the countries and not the cities, for example USA, AUS, NZ, UK etc. Hopefully there is a easy way for it to detect the same countries and add them all up.

 

Any help will be greatly appreciated! 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @sorathecat ,

 

You can create columns like DAX below.

 

Country =
var FirstComma = FIND(",",'Table1'[Location],1)
var SecondComma = FIND(",",'Table1'[Location],FirstComma + 1)
var LengthOfString = LEN('Table1'[Location])
return
MID('Table1'[Location],SecondComma + 1, LengthOfString - SecondComma + 1)
 
City =
var FirstComma = FIND(",",'Table1'[Location],1)
var SecondComma = FIND(",",'Table1'[Location],FirstComma + 1)
return
LEFT(Table1[Location],SecondComma-1)
 

 

 

75.png

 

 

 

Best Regards,

Amy

 

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

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi @sorathecat ,

 

You can create columns like DAX below.

 

Country =
var FirstComma = FIND(",",'Table1'[Location],1)
var SecondComma = FIND(",",'Table1'[Location],FirstComma + 1)
var LengthOfString = LEN('Table1'[Location])
return
MID('Table1'[Location],SecondComma + 1, LengthOfString - SecondComma + 1)
 
City =
var FirstComma = FIND(",",'Table1'[Location],1)
var SecondComma = FIND(",",'Table1'[Location],FirstComma + 1)
return
LEFT(Table1[Location],SecondComma-1)
 

 

 

75.png

 

 

 

Best Regards,

Amy

 

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

Anonymous
Not applicable

Hi @sorathecat,

 

The Power Query Editor makes this possible! The first thing you're going to want to do is to open the query editor and navigate to the "add column" ribbon. You will click on extract, as shown in the visual below.

ExtractColumn.PNG

 

You will use text after delimiter.  Use the screenshot below to enter in the values.

 

Extract Column2.PNG

Once you click ok, you should end up with two columns like the screenshot below.  Make sure to rename the column! This will allow you to group by country.

 

ExtractColumn3.PNG

 

You can also do this using DAX. If you want to know how to do that, let me know!

 

Hope this helped!

Hi @Anonymous 

 

Thank you!If you can let me know how to do this as a DAX formula will be great because i am building a dashboard on an app and will be manually updating the excel file every few weeks so i want the visualization to update automatically without much modifications as possible in BI! 

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.