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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
adrien5555
Helper II
Helper II

Creating a geographical hierarchy : Continent > Country

Hi all,

 

Brand new on PBI, so please excuse these trivial questions 🙂

 

How to indicate that a column is for geo data, like countries? 

 

It indicates for some of my csv data sources, but not for others. 

 

Also, how to create a hierarchy of continent > country ? Is it by adding a column and an IF condition like (IF country is (US or United States) THEN 'North America' ?

 

Thanks a lot,

 

1 ACCEPTED SOLUTION

@adrien5555 Actually there is an easy way. I replicated your scenario with Actual table (with values) and a table wth continents and countries (lookup table) and loaded it into powerbi desktop.

 

1.JPG

 

2.JPG

 

 

Go to query editor -> select values table -> Merge queries -> select matching columns from both table (countries column) -> left outer as join kind -> OK.

 

3.JPG

 

4.JPG

 

5.JPG

 

This will give you matching Continent from the lookup table

 

 

View solution in original post

7 REPLIES 7
ankitpatira
Community Champion
Community Champion

@adrien5555 In powerbi desktop under Data view, select column, under modelling table, under Data Category dropdown you can select type.

 

Capture.JPG

 

 

 

 

 

 

 

Yes you can use conditional formatting option introduced in april powerbi desktop update to have continets for each countries (if you dont have large number of countries you can do manually for each). 

@ankitpatira : Great! Is there maybe a well-known formula to add a new column 'Continent' with the proper values, depending on a 'Country' column?

@adrien5555 If you're familiar with DAX you can use LOOKUPVALUE function. What you can do is have a table with list of all the continents and countries (just google it i am sure you will find plenty). Import that. Create custom column and use LOOKUPVALUE function to update that column with contients with matching country names.

 

Let me know if you need hand and I can do a demo for you.

@ankitpatira : thx, really see the point here. Got a new dataset with continents and countries. 

 

Creating a Lookupvalue is a bit too much for me at this point... Any help very much appreciated. 

 

Is it like :

IF (country in dataset1 match country in dataset2) THEN (Field value is equals to corresponding value //continent// in dataset2)

?

 

Tried to create a relationship between other dataset with a 'country' field, but I got this :

 

 

 test.png

@adrien5555 Actually there is an easy way. I replicated your scenario with Actual table (with values) and a table wth continents and countries (lookup table) and loaded it into powerbi desktop.

 

1.JPG

 

2.JPG

 

 

Go to query editor -> select values table -> Merge queries -> select matching columns from both table (countries column) -> left outer as join kind -> OK.

 

3.JPG

 

4.JPG

 

5.JPG

 

This will give you matching Continent from the lookup table

 

 

@ankitpatira: So cool thanks so much !

 

Having another problem to refresh the dataset, but the preview in the Query Editor looks just perfect.

 

thanks !

asocorro
Skilled Sharer
Skilled Sharer

In Data view, select the field and go here:

 

g.png

 

For hierarchies, just drag and drop fields on top of others in the Report view.

 

 

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.