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.
Hi All,
Based on lng and lat I want to find top 10 closest locations when using drillthrough on specific cost center. Any ideas?
Hi @Krcmajster
Maybe you can do something like below:
Distance =
VAR __cc = SELECTEDVALUE( dimCC[Site Name]; FIRSTNONBLANK( dimCC[Site Name]; 1))
VAR __siteLat = CALCULATE( MAX( dimCC[Lat]); dimCC[Site Name] = __cc)
VAR __siteLong = CALCULATE( MAX( dimCC[Lon]); dimCC[Site Name] = __cc)
RETURN
// Distance in km
ACOS(
COS( RADIANS( 90 - MAX( DimXX[lat])))*
COS( RADIANS( 90 - __siteLat)) +
SIN( RADIANS( 90 - MAX( DimXX[lat])))*
SIN( RADIANS( 90 - __siteLat)) *
COS( RADIANS( MAX( DimXX[long]) - __siteLong))
)*6371
And then create a TOPN measure:
top10 =
TOPN(
10;
SUMMARIZE(
DimXX;
"Distance"; [Distance]
);
[Distance]; ASC
)
It is not the fastest measure if you have many observations, but I believe it will work. If you have a lot of observations you should consider moving the calculations to the queries.
If this answer helps then please mark it as the accepted solution. Kudos is also appreciated.
@Anonymous Thanks
So in my case let's say it would look like this:
Hi @Krcmajster
I'm not quite sure that it will and neither that the TOPN function works as it should. But it is just an idea which might be able to lead you in the right direction.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |