在 Power BI table 中创建 'new column' 时,我的 dax 公式 运行 可以与另一个(小)table 的所有行进行比较吗?

When creating a 'new column' in a Power BI table, can my dax formula run a comparison with all rows of another (small) table?

我在 Power BI 中有一个大型(实时)table,其中包括 easting/northing 位置数据。 (东距和北距是距固定原点的距离(以米为单位,因此形成 x-y 网格)。

我还有一个较小的 table,固定位置数量有限(~20),格式为 easting/northing。

我想在大 table 中添加一列,以显示到较小 table 中最近点的距离。 (这是使用毕达哥拉斯完成的:sqrt(Δeasting²+Δnorthing²))。

如有任何帮助,我们将不胜感激。谢谢。

编辑 - 示例数据:

large_table

eastlarge northlarge
104 103
205 212
209 240
328 345

small_table

eastsmall northsmall
100 100
200 200
300 300

我可以手动计算large_table中的新列,但显然我需要实现一个公式:

large_table

eastlarge northlarge min_distance
104 103 5
205 212 13
209 240 41
328 345 53

这是一个计算列:

Minimum Distance = 
VAR _easting = large_table[eastlarge]
VAR _northing = large_table[northlarge]
RETURN
MINX ( 
    ADDCOLUMNS ( 
        small_table ,
        "dist" , SQRT ( ( small_table[eastsmall] - _easting )^2 + ( small_table[northsmall] - _northing )^2 )
    ),
    [dist]
)

结果:

您也可以使用一个度量,使用相同的代码稍作调整:

Min Distance := 
VAR _easting = SELECTEDVALUE ( large_table[eastlarge] )
VAR _northing = SELECTEDVALUE ( large_table[northlarge] )
RETURN
MINX ( 
    ADDCOLUMNS ( 
        small_table ,
        "dist" , SQRT ( ( small_table[eastsmall] - _easting )^2 + ( small_table[northsmall] - _northing )^2 )
    ),
    [dist]
)

看起来像这样:

您可以在电源查询中执行此操作。 首先生成一个table结合大小tables。 然后创建一个计算列 'distance' 然后使用 summerize 函数分组