简体   繁体   English

如何使用来自不同表的 2 列在 PowerBI 中执行 IF 语句?

[英]How to do a IF statement in PowerBI using 2 columns from different tables?

I'm struggling with something that should be simple:我正在为一些应该很简单的事情而苦苦挣扎:

IF Column A in table 1 = Column B in table 2 then "No Change" else "Change"如果表 1 中的 A 列 = 表 2 中的 B 列,则“无变化”,否则“变化”

I tried creating a new column under table 1 using this:我尝试使用以下方法在表 1 下创建一个新列:

ActionItem = IF((Column A] = related(table2[ColumnB]), "No Change", "Change")

I do have [one to many] relationship between the tables我在表之间确实有 [一对多] 关系

Thanks for your help in advance提前感谢您的帮助

Is this a measure or column?这是度量还是列? if a measure then you need to wrap the column references with a formula (eg. sum, count, values, etc).如果是度量,那么您需要用公式(例如总和、计数、值等)包装列引用。

If there already exists a relationship between the columns then you don't need the related().如果列之间已经存在关系,则不需要 related()。

If this is in a calculated column then it should work as long as the relationship is set up directly.如果这是在计算列中,那么只要关系是直接设置的,它就应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM