无关联表多条件下,使用DAX从另一表查找值的方法
无关联表多条件匹配Rate的DAX公式
你可以使用LOOKUPVALUE函数实现需求,它专门用于无关联表间的多条件匹配取值,刚好适配你提到的「Table A中Duration、Currency、Type组合对应唯一Rate值」的前提。
在Table B中新建列的DAX公式如下:
Rate = LOOKUPVALUE( TableA[Rate], TableA[Duration], TableB[Duration], TableA[Currency], TableB[Currency], TableA[Type], TableB[Type] )
补充说明:
如果Table A中存在相同Duration+Currency+Type组合对应多个Rate值的情况,LOOKUPVALUE会返回错误。此时需要先对Table A做去重处理,比如用SUMMARIZE生成仅含唯一组合及对应Rate的临时表,再进行匹配:
Rate = VAR UniqueTableA = SUMMARIZE( TableA, TableA[Duration], TableA[Currency], TableA[Type], "UniqueRate", MAX(TableA[Rate]) // 相同组合下Rate取最大值,可根据实际需求调整聚合逻辑 ) RETURN LOOKUPVALUE( UniqueTableA[UniqueRate], UniqueTableA[Duration], TableB[Duration], UniqueTableA[Currency], TableB[Currency], UniqueTableA[Type], TableB[Type] )
内容的提问来源于stack exchange,提问作者Stagflator
相关产品推荐
相关产品推荐

