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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.