1

I am having trouble with a calculated column I am trying to develop. I have two tables:

(I don't know why the tables aren't displaying properly. It looks fine in preview)

Table A:

PK Calculated column
1 Value wanted in caluculated column row 1
2 Value wanted in caluculated column row 2

Table B:

PK Table A ID Wanted Value Date param
1 1 Value wanted in caluculated column row 1 2020/10/08
2 1 Value not wanted 2020/04/04
3 2 Value wanted in caluculated column row 2 2021/01/07
4 3 Value not wanted 2022/04/12
5 3 Value wanted in caluculated column row 3 2023/01/02

What I am stuck on is the DAX code to create a calculated column (Named "Calculated Column" in the example tables) that will take the value from the "Wanted Value" column in table B, based on which Table B row is the most recent regarding the "Date param" column value.

Any help is greatly appreciated. Thanks in advance.

PS: Please tell me if any additional details are required. Also, I normally provide my current code when asking questions on SO, but in this case, I don't even know where to start.

Shiverz
  • 663
  • 1
  • 8
  • 23
  • Do you have a relationship between Table A and Table B? Please update table A with the actual output you expect to see in the new column rather than question marks. – Davide Bacci May 23 '23 at 15:52
  • I do have a 1..n relationship from table A to table B. – Shiverz May 24 '23 at 00:51

1 Answers1

1

UPDATED

Here you go:

Calculated column = 
VAR m = CALCULATE( MAX('Table B'[Date param]))
RETURN
CALCULATE( MAX('Table B'[Wanted Value]), 'Table B'[Date param] = m)

enter image description here

enter image description here

enter image description here

Davide Bacci
  • 16,647
  • 3
  • 10
  • 36