PowerBI Dax 查询 - 匹配一个值并获得其最大值
PowerBI Dax Query - Match a Value and get its Maximum Value
我想将一个 table 的 Column1 中的值与另一个匹配,并获得 column2 的最大值。
例如我有两个 tables,
Table 1
Col1 Col2
AA 17
AA 20
AB 10
AB 21
Table 2
Col1 Col2
AA ?
AB ?
我希望我的输出看起来像这样,
Col1 Col2
AA 20
AB 21
我试过了,
Col2 = Max(Table1[col2])
但这并没有帮助。谢谢。请分享您的想法。
您可以使用以下 DAX:
Col2 =
CALCULATE(
MAX(Table1[Col2]),
FILTER(
Table1,
Table1[Col1] = Table2[Col1]
)
)
结果:
我想将一个 table 的 Column1 中的值与另一个匹配,并获得 column2 的最大值。
例如我有两个 tables,
Table 1
Col1 Col2
AA 17
AA 20
AB 10
AB 21
Table 2
Col1 Col2
AA ?
AB ?
我希望我的输出看起来像这样,
Col1 Col2
AA 20
AB 21
我试过了,
Col2 = Max(Table1[col2])
但这并没有帮助。谢谢。请分享您的想法。
您可以使用以下 DAX:
Col2 =
CALCULATE(
MAX(Table1[Col2]),
FILTER(
Table1,
Table1[Col1] = Table2[Col1]
)
)
结果: