英文:
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]))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论