Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I'm new to Power BI and DAX... I'm trying to create a calculated column that computes the distance between two points using latitude/longitude.
I have a primary table with address information including zip codes and a lookup table with all US Zip Codes and associated latitude/longitude data. I have a What-If Parameter to get User input for a single Zip Code value to compute the distances from that point to all other locations in the primary table. I can't seem to figure out how to select the zip code value from each row in the table for the calculation. The code I borrowed/adapted for the calculation is below (suspect values are underlined/bold below);
Kilometers = var Lat1 = LOOKUPVALUE(ZipCodes[Zip_Latitude],ZipCodes[Zip_Code], 'Recruiting Test-2'[Zip_Code]) var Lng1 = LOOKUPVALUE(ZipCodes[Zip_longitude],ZipCodes[Zip_Code], 'Recruiting Test-2'[Zip_Code]) var Lat2 = LOOKUPVALUE(ZipCodes[Zip_Latitude],ZipCodes[Zip_Code],From_Zip[From_Zip Value]) var Lng2 = LOOKUPVALUE(ZipCodes[Zip_longitude],ZipCodes[Zip_Code],From_Zip[From_Zip Value]) ---- Algorithm here ----- var P = DIVIDE( PI(), 180 ) var A = 0.5 - COS((Lat2-Lat1) * p)/2 + COS(Lat1 * p) * COS(lat2 * P) * (1-COS((Lng2- Lng1) * p))/2 var final = 12742 * ASIN((SQRT(A))) return final
I'm attempting to use the LOOKUPVALUE to set the latitude & longitude for each row of the table (Lat1 & Lng1), but it doesn't seem to be selecting the zip code from each row. The function does not return an error, but all of the values in the column are Zero.
Any help would be greatly appreciated...
Hi @Dean_Stanberry,
Have you solved the problem?
If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.
If you still need help, please share some data smaple and your desired output so that we could help further on it.
Best Regards,
Cherry
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.