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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
samahiji
Frequent Visitor

check if coordinates are within certain polygon

Hi,

I have two tables:

Table 1 contains all X Y coordinates 

Table 2 contains the polygon shape file coordinates,

 

I want to check which coordinates are within the polygon. 

 

 

1 ACCEPTED SOLUTION
ZhangKun
Super User
Super User

I used the sample data provided by @p45cal. Maybe you want this.

ZhangKun_0-1734540323004.png

 

View solution in original post

8 REPLIES 8
ZhangKun
Super User
Super User

I used the sample data provided by @p45cal. Maybe you want this.

ZhangKun_0-1734540323004.png

 

@samahiji You can leave your e-mail and i'll reply you with source code(about today or tomorrow).

p45cal
Super User
Super User

Yes, let's have some tables from you. Preferably in an app (say Excel as a workbook).

I've been working on polygons like this and have (I think) been successful (purely in Power Query) but I won't post my offering (because it's a mess, currently) until I have a good idea of how your data arrives and how you want it to show at the end.

 

p45cal_3-1734449210657.png

 

 

p45cal_4-1734449254840.png

 

 

Hi @p45cal ,

That's exactly what I want. My data is huge, attached is a sample of it. I have two tables, the polygon X&Y is in sheet "Polygon", the data point is in another sheet "Points". A new column "IN/OUT" in sheet "Points" is calculated with 0 if out, 1 if in.

 

unfortunately, I can't upload the file, here is a snapshot.

 

Polygon_Checker.JPG

 


My data is huge,
<snip>

unfortunately, I can't upload the file, here is a snapshot.


1. Upload it to a file sharing site or onedrive, dropbox, box.com, googledrive etc. there are loads of them, and drop the link to it here.

If it contains sensitive info delete all unnecessary sheets and just supply two tables on two sheets. Pictures aren't much use.

 

2. Does it have to be Power Query? Could it be a custom user-defined function in vba (a macro)?

 

Hi @samahiji,

We hope the steps provided by @p45cal@ZhangKun have resolved your issue. If yes give Kudos to the user and consider Accept as a solution to help other members find it more easily.

 If you have any further questions or need additional assistance, please reach out to us.

Thankyou.

v-sgandrathi
Community Support
Community Support

Hi @samahiji,
Thank you for reaching out to the Microsoft Fabric Community forum.

Here I have taken 2 sample datasets as per information and did the steps for your understanding, but it will be better for us to perform steps accurately and we can guide you accordingly if you can provide us the Data if possible.
This process can be done in many ways, where I followed DAX queries to perform.

 

For your Idea, I’ve attached the PBIX file with the implemented solution. Please review it and let us know is there any further questions.

If this post helps, please give us Kudos and consider Accept it as a solution to help the other members find it more easily.

 

Best Regards,
Sahasra.

Greg_Deckler
Super User
Super User

@samahiji Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.