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

DAX - Dynamic Measure based on slicer selection

Hello there! 

 

I need some guidance again please 🙂

 

I am using the following measure to calculate distance: 

MischaT_1-1638639618082.png

 

EVENT TABLE

IDPLACETYPELATLONG
01PRETORIAHAILSTORM-29,3384127,99473
02BLOEMSNOW-25,5273528,04517
03POTCHFLOODING-29,3384131,28885

 

WHAT I WOULD LIKE TO DO:

I would like to create a ID Slicer for the clients. 

 

Based on the selected ID on the slicer, I would like the measure to use the selected ID's LAT and LONG and calculate the distance from the selected ID. 

 

Any suggestions?

 

Would really apprecaite any assistance 

 

Kind Regards, M

 

 

1 ACCEPTED SOLUTION

@MischaT 

Get the lat, long of the site in the same fashion:

VAR IDLat = SELECTEDVALUE(EventTable[Lat])

VAR IDLong = SELECTEDVALUE(EventTable[Long])

VAR SiteLat = SELECTEDVALUE(SitesTable[Lat])

VAR SiteLong = SELECTEDVALUE(SitesTable[Long])

then apply your formulae.

If this does not work I'd probablyn need a mock pbix reproducing the issue so that I can see exactly what you are doing. You have to share the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

 

 

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi @MischaT 

 

As @AlB  mentioned, it's not clear how do you want to calculate a distance? do you want to replace the selected ID Lat and Long with Lat1 and Long 1 in your formula or Lat 2 and Long 2??? I think you want to replace that with Lat and Long 2!

 

Can you share a sample of DB_ISITES table?

 

 

BTW, if you select an ID on a slicer that will filter the EVENT table and then Lat1 and Long1 will return the Lat and Long of the selected ID.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

AlB
Super User
Super User

Hi @MischaT 

The distance between the selected ID and where?

You can read the selected ID coordinates simply by using:

VAR IDLat = SELECTEDVALUE(EventTable[Lat])

VAR IDLong = SELECTEDVALUE(EventTable[Long])

 

and then use that in hte formula you already have


SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

MischaT
Frequent Visitor

Hi @AlB,

 

Thank you for the response. 

 

I have tried using the SELECTEDVALUE, but unfortunately it still doesn't work. 

 

I would like to calculate the distance from the selected ID to each of the ISITES.

When an ID is then selected, the distance calculation then does not work correctly 

MischaT_0-1638785331421.png

 

@VahidDMDB_ISITES Table:

SITE NAMETYPEPROVLATLONG
TropicalBarGP-29,3385027,99473
SunsetCasinoKZN-29,3384031,28890

 

I'm very confused as to what is going wrong 

 

Thank you!

@MischaT 

Get the lat, long of the site in the same fashion:

VAR IDLat = SELECTEDVALUE(EventTable[Lat])

VAR IDLong = SELECTEDVALUE(EventTable[Long])

VAR SiteLat = SELECTEDVALUE(SitesTable[Lat])

VAR SiteLong = SELECTEDVALUE(SitesTable[Long])

then apply your formulae.

If this does not work I'd probablyn need a mock pbix reproducing the issue so that I can see exactly what you are doing. You have to share the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

 

 

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