Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 如果列表中包含另一个值(幂bi、dax),则指定值_If Statement_Powerbi_Dax - Fatal编程技术网

If statement 如果列表中包含另一个值(幂bi、dax),则指定值

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”

我在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”、“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,因此我还提供了一个不依赖于较新语法的版本。