Forum Discussion

DrHematite's avatar
DrHematite
Frequent Visitor
6 years ago
Solved

Get value from other row in same table

Hi everyone. Need some help. My data is formatted like this (extraneous columns removed) (dates dd/mm/yyyy)

Serial1Date1Serial2Date2
abc01/01/2019bcd01/05/2019
bcd06/07/2019cde08/10/2019
cde01/11/2019def02/03/2020
vwx02/01/2019wxy02/05/2019
wxy05/06/2019xyz13/08/2019
xyz12/10/2019

yza

02/02/2020

 

So what I'm trying to do is, create a calculated column that for a given row returns the EARLIEST value of Date1 that satisfies the following criteria
Serial1 in the row from which date1 is selected = Serial2 in the original row, selected value of Date1 >= Date2 in the original row.

I've tried this:
Date3 = CALCULATE(
    FIRSTDATE(TableName[Date1]),
    TableName[Date1] >= EARLIER(TableName[Date2]),
    TableName[Serial1] = Earlier(TableName[Serial2])
)
To no avail, I end up getting a circular dependency error, between the calculated column and a hex value that appears to be a memory address.

 

The result should come out:

Serial1Date1Serial2Date2Date3
abc01/01/2019bcd01/05/201906/07/2019
bcd06/07/2019cde08/10/201901/11/2019
cde01/11/2019def02/03/2020<blank>
vwx02/01/2019wxy02/05/201905/06/2019
wxy05/06/2019xyz13/08/201912/10/2019
xyz12/10/2019

yza

02/02/2020

<blank>


Would appreciate some help!

  • I did the following:

     

    Date3 = 
        MINX(
            FILTER('Table',
                'Table'[Date1] >= EARLIER('Table'[Date2]) &&
                'Table'[Serial1] = Earlier('Table'[Serial2])
            ),
            [Date1]
        )

     

    PBIX is attached.

     

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    I did the following:

     

    Date3 = 
        MINX(
            FILTER('Table',
                'Table'[Date1] >= EARLIER('Table'[Date2]) &&
                'Table'[Serial1] = Earlier('Table'[Serial2])
            ),
            [Date1]
        )

     

    PBIX is attached.