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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
GettingThere
Frequent Visitor

Dynamic coordinates depending on hierarchy

Hi, 

I have a hierarchy of geography containing 4 levels. My report has drill-down through each of these geographies and that works well on chart visuals. However, I want to include a custom tooltip which shows the location on a map using X & Y coordinates when hovering over a bar. To achieve this I need the co-ordinates to dynamically change depending upon the hierarchy within the chart. 

 

I have written the below measure which correctly returns the X_Coord and works if I add the measure as a column to a matrix, however it retuns blank when I add the measure to Longitude in the Map visual. I have the equivalent measure for latitude too.

 
XCoord=
SWITCH
(
TRUE,
ISINSCOPE(Dim_Destination[CentreName]),MAX(Dim_Destination[X_WGS84]),
ISINSCOPE(Dim_Destination[TradeZoneName]),MAX(Dim_Destination[TZ_X_WGS84]),
ISINSCOPE(Dim_Destination[SuperTradeZoneName]),MAX(Dim_Destination[STZ_X_WGS84]),
ISINSCOPE(Dim_Destination[StandardRegion]),MAX(Dim_Destination[SR_X_WGS84]),
1
)
 
I have spent a long time looking for suggested solutions but I'm stuck. Is it possible to achieve this? 
 
Hopefully this link to my pbix works! https://we.tl/t-PldXRYhmVd
 
Thanks in advance for your help!
 
1 ACCEPTED SOLUTION

@GettingThere  This might not be the most efficient way, but it works: 

 

AllisonKennedy_0-1644620718778.png

I stacked all locations in one column so there's only one lat column and one long column, (did this in Power Query).

 

Then created a measure to filter the new Locations stacked table:

 

Filter_HASONEVALUE =

VAR _LocationID =
SWITCH(
TRUE,
HASONEVALUE(Dim_Destination[CentreName]),"C" & SELECTEDVALUE(Dim_Destination[CentreID]),
HASONEVALUE(Dim_Destination[TradeZoneName]),"TZ" & SELECTEDVALUE(Dim_Destination[SuperTradeZoneID]),
HASONEVALUE(Dim_Destination[SuperTradeZoneName]),"STZ" & SELECTEDVALUE(Dim_Destination[SuperTradeZoneID]),
HASONEVALUE(Dim_Destination[StandardRegion]),"SR " & SELECTEDVALUE(Dim_Destination[StandardRegion])
)
VAR _FilterLocations =
FILTER(Locations,
Locations[SourceID] = _LocationID
)
VAR _Result = COUNTROWS(_FilterLocations)
RETURN _Result
 
See file below signature.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
GettingThere
Frequent Visitor

@AllisonKennedy thank you for your suggestion, but it would be misleading for the report viewer. Ideally the coordinates would interact with the hierarchy. 

 

@GettingThere  This might not be the most efficient way, but it works: 

 

AllisonKennedy_0-1644620718778.png

I stacked all locations in one column so there's only one lat column and one long column, (did this in Power Query).

 

Then created a measure to filter the new Locations stacked table:

 

Filter_HASONEVALUE =

VAR _LocationID =
SWITCH(
TRUE,
HASONEVALUE(Dim_Destination[CentreName]),"C" & SELECTEDVALUE(Dim_Destination[CentreID]),
HASONEVALUE(Dim_Destination[TradeZoneName]),"TZ" & SELECTEDVALUE(Dim_Destination[SuperTradeZoneID]),
HASONEVALUE(Dim_Destination[SuperTradeZoneName]),"STZ" & SELECTEDVALUE(Dim_Destination[SuperTradeZoneID]),
HASONEVALUE(Dim_Destination[StandardRegion]),"SR " & SELECTEDVALUE(Dim_Destination[StandardRegion])
)
VAR _FilterLocations =
FILTER(Locations,
Locations[SourceID] = _LocationID
)
VAR _Result = COUNTROWS(_FilterLocations)
RETURN _Result
 
See file below signature.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

@GettingThere would it suffice to display all the child coordinates when hovering over parent hierarchy? 

AllisonKennedy_0-1644581853328.png

 

https://excelwithallison.blogspot.com/2021/09/tooltips-in-power-bi.html 

see attached file below signature.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors