I'm attempting to write a report where I am connecting replaced assets.
Here is a simplified table of the report as it is currently:
| Column A | Column B | Column C | Column D |
|---|---|---|---|
| 321 | 123 | 124 | |
| 323 | 124 | null | |
| 324 | 125 | null |
I am attempting to use a formula to populate Column D. The idea is that when any value in Column C matches any value in Column B, retrieve the value of Column A for the matched value in Column B.
In my example, because 124 is in both Column C and B, I want to populate row 1, Column D with 323.
For context, all columns are from the same table and the columns are automatically selected, the column results are all formatted as plain text, and Column A values will all be distinct, Column B values will also always be distinct, and Column C can have one or more of the same values in Column B, though for this purpose we can assume they are distinct values as well.
Thank you!
I've attempted to use the following (omitting the select and from clauses as they are automatically input):
CASE WHEN "Column C"="Column B"
THEN "Column A"
ELSE null END
This only produces the ELSE condition in Column D. I was hoping to get the value of Column A, row 2 because of the matched value in Column B, row 2.
Then I was able to populate Column D with:
CASE WHEN "Column C"
IN( SELECT "Column B" FROM "TABLE")
THEN "COLUMN A"
ELSE null END
This evaluated the expression correctly and populated Column D, but now with the row's value for Column A. See result below:
| Column A | Column B | Column C | Column D |
|---|---|---|---|
| 321 | 123 | 124 | 321 |
| 323 | 124 | null | |
| 324 | 125 | null |
I was hoping to populate Column D with 323. How can I get the value of Column A, row 2 into Column D, row 1?
Thank you!
If I got it right, you should join your dataset to itself like below. Added some rows to sample data for testing...