Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Compare two dates from different tables, using if condition

I have two tables, Table 1 and Table 2, both are related based on account number.

 

I want to compare if date from table 1 = date from table 2, if is not the same then "different" is it is the same then "equal". How can I do an if statement, comparing both dates row by row so I can add it to table.

7 Replies

  • You may be able to use the LOOKUPVALUE function in this case. 
    As an example I have two tables
    Table 1

    Date Account
    3/3/2024 ABC
    3/3/2024 DEF
    3/4/2024 ABC
    3/5/2024 GHI
    3/5/2024 DEF

    and Table 2

    Date Account
    3/3/2024 ABC
    3/4/2024 DEF
    3/5/2024 GHI

     

    and I want to know if the values in Table 1 appear in Table 2. 
    I can add a calculated column to Table 1 with the following code...

    isOnTable2 = 
    var _lookup = 
    LOOKUPVALUE('Table 2'[Account], 'Table 2'[Account], [Account], 'Table 2'[Date], [Date])
    Return
    IF(
        _lookup = [Account],
        "Yes",
        "No"
    )

    and end up with the result...

    Hope this gets you pointed in the right direction.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, is not working, see the following example I am getting  

       

      • jgeddes's avatar
        jgeddes
        Super User

        If you can provide a sample of your data (nothing sensitive) I will likely be able to provide a better solution for you.