<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4263028#M168967</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="831033" data-lia-user-login="LeopoldoG" class="lia-mention lia-mention-user"&gt;LeopoldoG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can the following expression to get the coordinates in the slicer:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SelectedItemX = 
CALCULATE(
    MAX('Table'[X]),
    'Table'[CT] = SELECTEDVALUE('Table'[CT])
)

SelectedItemY = 
CALCULATE(
    MAX('Table'[Y]),
    'Table'[CT] = SELECTEDVALUE('Table'[CT])
)

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope it helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Scott Chang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2024 01:29:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-10-30T01:29:04Z</dc:date>
    <item>
      <title>How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4260374#M168838</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello everyone,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm working on a &lt;STRONG&gt;Power BI&lt;/STRONG&gt; report with data that includes &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;X&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; and&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Y&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; coordinates for each item. I'd like to implement a feature that allows users to select an item and see a list or table displaying the closest items to it.&amp;nbsp;I was able to calculate the distance of each item to a fixed coordinate in a column, but I couldn’t make that reference coordinate change based on the item selected in the slicer.&lt;/P&gt;&lt;H3&gt;Current Setup:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;A dataset with &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;X&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; and &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Y&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; coordinates columns for each item.&lt;/LI&gt;&lt;LI&gt;A data slicer that allows the selection of a specific item.&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Objective:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate the distance&lt;/STRONG&gt; between the selected item and other items.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Sort&lt;/STRONG&gt; these items based on their proximity to the selected item.&lt;/LI&gt;&lt;LI&gt;Display the nearest items in a &lt;STRONG&gt;table&lt;/STRONG&gt; or other visualization in Power BI.&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Questions:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;Is it possible to achieve this directly in Power BI using DAX or any other built-in functionality?&lt;/LI&gt;&lt;LI&gt;Is there an alternative approach to display the nearest items based on coordinates, perhaps using a map visual or a custom visual in Power BI?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you in advance for any suggestions or DAX examples you can provide!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 10:50:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4260374#M168838</guid>
      <dc:creator>LeopoldoG</dc:creator>
      <dc:date>2024-10-28T10:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4260464#M168840</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="831033" data-lia-user-login="LeopoldoG" class="lia-mention lia-mention-user"&gt;LeopoldoG&lt;/a&gt;&amp;nbsp;This should be helpful. If you can provide sample data, I can probably modify this to work for what you are trying to do:&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Near/m-p/1360099#M616" target="_blank"&gt;Near - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 12:09:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4260464#M168840</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-10-28T12:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4261374#M168889</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="831033" data-lia-user-login="LeopoldoG" class="lia-mention lia-mention-user"&gt;LeopoldoG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure about your data model, but you can generally try the following expression:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SelectedX = SELECTEDVALUE(YourTable[X])
SelectedY = SELECTEDVALUE(YourTable[Y])

Distance = 
VAR SelectedX = [SelectedX]
VAR SelectedY = [SelectedY]
RETURN
    SQRT(POWER(YourTable[X] - SelectedX, 2) + POWER(YourTable[Y] - SelectedY, 2))

Rank = 
RANKX(
    ALL(YourTable),
    [Distance],
    ,
    ASC
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope it helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Scott Chang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 02:22:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4261374#M168889</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-29T02:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4262180#M168930</link>
      <description>&lt;P&gt;Thank you for your response! I actually tried something similar, but it doesn’t work as expected. It calculates the distance between each item and itself, rather than using the coordinates of the selected item in the slicer.&lt;/P&gt;&lt;P&gt;The data model:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 11:40:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4262180#M168930</guid>
      <dc:creator>LeopoldoG</dc:creator>
      <dc:date>2024-10-29T11:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Nearest Elements to a Selected Item Using X and Y Coordinates in Power BI?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4263028#M168967</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="831033" data-lia-user-login="LeopoldoG" class="lia-mention lia-mention-user"&gt;LeopoldoG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can the following expression to get the coordinates in the slicer:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SelectedItemX = 
CALCULATE(
    MAX('Table'[X]),
    'Table'[CT] = SELECTEDVALUE('Table'[CT])
)

SelectedItemY = 
CALCULATE(
    MAX('Table'[Y]),
    'Table'[CT] = SELECTEDVALUE('Table'[CT])
)

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope it helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Scott Chang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 01:29:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Find-Nearest-Elements-to-a-Selected-Item-Using-X-and-Y/m-p/4263028#M168967</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-30T01:29:04Z</dc:date>
    </item>
  </channel>
</rss>

