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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
NJ81858
Helper IV
Helper IV

Iterating through table

Hello,

 

My organization is running a marketing campaign to send a letter to all customers from the location that is closest to them, instead of the location that they first made a purchase at, since that is the location that is connected to the customer in our data structure, and they may be different locations. I have a table of all addresses and longitude/latitude for all customers, and I have another table that has the same information for my organization's locations. How would I go about creating a formula that iterates through all organization locations to find the closest one in distance for each customer? Thank you in advance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@NJ81858 , for each transaction, make sure you lat log, and you can find min distance with your organization using lat log

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Finding-Minimum-Haversine-Distance-from-two-s...

 

You can loop in using a column and maxx/minx function

 

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@NJ81858 , for each transaction, make sure you lat log, and you can find min distance with your organization using lat log

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Finding-Minimum-Haversine-Distance-from-two-s...

 

You can loop in using a column and maxx/minx function

 

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors