将值根据条件从另一个表插入到表中的DAX操作。

huangapple go评论43阅读模式
英文:

DAX - Inserting value into table from other table based on condition

问题

我有两个表格:

表格 A(一个简单的三行表格):

年份 目标
2021 2
2022 3
2023 3.5

表格 B:

日期
10/09/2021 23
30/10/2021 24.4
22/05/2022 34
10/09/2022 23
11/03/2023 23.6
23/09/2023 27
等等... 等等...

这两个表格之间没有关系。

我需要在表格 B 中创建一个计算列,该列将基于表格 A 的年份是否等于表格 B 的日期来显示表格 A 的目标。如下所示:

日期 我的计算列
10/09/2021 23 2
30/10/2021 24.4 2
22/05/2022 34 3
10/09/2022 23 3
11/03/2023 23.6 3.5
23/09/2023 27 3.5
等等... 等等... 等等...

然而,我不知道如何创建这样的计算列。非常感谢您提前的帮助!

英文:

I have two tables:

Table A (A simple 3 line table):

Year Objective
2021 2
2022 3
2023 3.5

Table B:

Date Value
10/09/2021 23
30/10/2021 24.4
22/05/2022 34
10/09/2022 23
11/03/2023 23.6
23/09/2023 27
ect... ect...

There is no relationship between these two tables.

What I need is a calculated column in Table B that will show the tableA.Objective based on if tableA.Year is equal to the year of TableB.Date. Like so:

Date Value My calculated column
10/09/2021 23 2
30/10/2021 24.4 2
22/05/2022 34 3
10/09/2022 23 3
11/03/2023 23.6 3.5
23/09/2023 27 3.5
etc... etc... etc...

However, I don't know how to create such a calculated column. Any help is greatly appreciated.

Thanks in advance!

答案1

得分: 1

根据Ashok的建议,

我的计算列 = LOOKUPVALUE(TableA[目标], TableA[年份], YEAR(TableB[日期]))
英文:

As Ashok suggested,

My calculated column = LOOKUPVALUE(TableA[Objective], TableA[Year], YEAR(TableB[Date]))

huangapple
  • 本文由 发表于 2023年6月15日 16:38:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定