Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
| Continnet_pk | Continent_name |
| 11 | Europa |
| 22 | Asia |
| Country_PK | Country_name |
| 101 | Germany |
| 202 | Austria |
| City_PK | City_name |
| 111 | Berlin |
| 222 | Vienna |
| ForeignKey | Score |
| 11 | 100 |
| 22 | 200 |
| 101 | 1100 |
| 202 | 2200 |
| 111 | 111000 |
| 222 | 222000 |
| Name | Score |
| - Europa | 100 |
| - Germany | 101 |
| - Berlin | 111000 |
| - Austria | 202 |
| - Vienna | 222000 |
| Asia | 202 |
Solved! Go to Solution.
Hi @Anonymous ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create a dimension to explain the hierarchies among continent, country and city
2. Create a measure as below to get the score
Measure =
VAR _selcont =
SELECTEDVALUE ( 'Table'[Continnet_pk] )
VAR _selcountry =
SELECTEDVALUE ( 'Table'[Country_PK] )
VAR _selcity =
SELECTEDVALUE ( 'Table'[City_PK] )
RETURN
CALCULATE (
SUM ( 'Rating'[Score] ),
FILTER (
'Rating',
'Rating'[ForeignKey]
= IF (
ISINSCOPE ( 'Continent'[Continent_name] )
&& NOT ( ISINSCOPE ( 'Country'[Country_name] ) )
&& NOT ( ISINSCOPE ( 'City'[City_name] ) ),
_selcont,
IF (
ISINSCOPE ( 'Continent'[Continent_name] )
&& ISINSCOPE ( 'Country'[Country_name] )
&& NOT ( ISINSCOPE ( 'City'[City_name] ) ),
_selcountry,
_selcity
)
)
)
)
Best Regards
Hi @Anonymous ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create a dimension to explain the hierarchies among continent, country and city
2. Create a measure as below to get the score
Measure =
VAR _selcont =
SELECTEDVALUE ( 'Table'[Continnet_pk] )
VAR _selcountry =
SELECTEDVALUE ( 'Table'[Country_PK] )
VAR _selcity =
SELECTEDVALUE ( 'Table'[City_PK] )
RETURN
CALCULATE (
SUM ( 'Rating'[Score] ),
FILTER (
'Rating',
'Rating'[ForeignKey]
= IF (
ISINSCOPE ( 'Continent'[Continent_name] )
&& NOT ( ISINSCOPE ( 'Country'[Country_name] ) )
&& NOT ( ISINSCOPE ( 'City'[City_name] ) ),
_selcont,
IF (
ISINSCOPE ( 'Continent'[Continent_name] )
&& ISINSCOPE ( 'Country'[Country_name] )
&& NOT ( ISINSCOPE ( 'City'[City_name] ) ),
_selcountry,
_selcity
)
)
)
)
Best Regards
Hi v-yiruan-msft ,
Thanks for the solution! It does the job.
The only issue I have found (after testing this unfortunately), that the same city can be in both countries through different continents as well. Is it still possible to fit it into this measure?
Hi @Anonymous ,
Thanks for your feedback. Do you mean that one city can be belong to multiple continents? If yes, then you can add these info in the dimension table. For example: city aa, it has two continents: a1 and a2. And its country is a. Then you can add the data in the dimension table as below:
Best Regards
Refactor your data model. Your Country table is a sub-dimension of the Continent table so it should contain the foreign key (and the score if you want).
Worst case you can denormalize the whole thing into a City - Country - Continent table. The cardinality is still small enough for that to work.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.