本文介绍了Power BI-根据纬度/经度查找最近的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是Power BI和DAX的新手,所以希望您能为我提供帮助。I am new to Power BI and DAX, so I hope you can help me.我有两个没有任何关系的表: 表A 包含经纬度的经纬度和日期。 表B 包含经度/纬度和所有体育场的名称。I have two tables without any relationship:Table A contains lat/lng and date of tracked positions.Table B contains lat/lng and names of all stadiums.我想找到最靠近跟踪位置的体育场。另外,如果可能的话,我想验证一下该位置是否在该体育场的特定半径内。I want to find the closest stadium near the tracked position. Also if possible I want to validate, if the position was in a specific radius of that stadium.任何帮助都将不胜感激。Any help greatly appreciated.推荐答案这里是一种可能的方法:Here's one possible approach:首先,计算将其作为计算列添加到 Tracked 表中。Add this as a calculated column to your Tracked table.Nearest = MINX(Stadiums, ROUND(2 * 3959 * ASIN(SQRT( SIN((Stadiums[Lat] - Tracked[Lat]) * PI()/360)^2 + COS(Tracked[Lat] * PI()/180) * COS(Stadiums[Lat] * PI()/180) * SIN((Stadiums[Lon] - Tracked[Lon]) * PI()/360)^2)), 1))在此公式中, 3959 是地球的半径,以英里为单位。In this formula, 3959 is the radius of the Earth in miles.我们现在可以匹配距离以找到最近的体育场:We can now match up distances to find the nearest stadium:Stadium = CALCULATE(MAX(Stadiums[Stadium]), FILTER(Stadiums, ROUND(2 * 3959 * ASIN(SQRT( SIN((Stadiums[Lat] - Tracked[Lat]) * PI()/360)^2 + COS(Tracked[Lat] * PI()/180) * COS(Stadiums[Lat] * PI()/180) * SIN((Stadiums[Lon] - Tracked[Lon]) * PI()/360)^2)), 1) = Tracked[Nearest])) 注意:我对这些值进行了四舍五入,以避免与可能的浮点错误不匹配。Note: I rounded the values to avoid not matching from possible floating point errors. This may or may not be necessary. 这篇关于Power BI-根据纬度/经度查找最近的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!