If statement 如果列表中包含另一个值(幂bi、dax),则指定值
我在Power BI中导入了一个表,如下所示:If statement 如果列表中包含另一个值(幂bi、dax),则指定值,if-statement,powerbi,dax,If Statement,Powerbi,Dax,我在Power BI中导入了一个表,如下所示: id value 01 123 02 456 03 789 04 999 id value KIND 01 123 baker 02 456 baker 03 789 other 04 999 other 我想使用IF语句声明一个名为KIND的新列。大致如下: KIND=if(id位于(“01”、“02”、“22”、“89”)、“baker”
id value
01 123
02 456
03 789
04 999
id value KIND
01 123 baker
02 456 baker
03 789 other
04 999 other
我想使用IF
语句声明一个名为KIND
的新列。大致如下:
KIND=if(id位于(“01”、“02”、“22”、“89”)、“baker”、“other”)
预期结果如下所示:
id value
01 123
02 456
03 789
04 999
id value KIND
01 123 baker
02 456 baker
03 789 other
04 999 other
这不仅仅是评论中的答案:
KIND := IF ( TableName[id] IN {"01", "02", "22", "89"}, "baker", "other" )
请注意,中的功能在某些旧版本的Excel中不起作用,您必须使用CONTAINSROW
KIND := IF ( CONTAINSROW ( {"01", "02", "22", "89"}, TableName[id] ), "baker", "other" )
如果(id在{“01”、“02”、“22”、“89”},“baker”、“other”)中起作用。你想把它作为一个答案吗?我一直在等待有人在评论中把答案作为问题的答案,哈哈。不管怎样,为什么要使用:=
,Excel的向后兼容性与此有什么关系?是可选的,但有时用于区分计算列和度量值。DAX也用于Excel Power Pivot,因此我还提供了一个不依赖于较新语法的版本。