Forum Discussion

NewbiePowerBye's avatar
8 years ago
Solved

If Condition: Date comparison from two different tables

Hello,   I have the following tables(as a preview):   Table A:   ID     InProgressDate    SolvedDate 1       2/5/2018                2/7/2018 2       2/6/2018               2/8/2018 3       ...
  • Greg_Deckler's avatar
    8 years ago

    I would think that your column would go something along the lines of:

     

    Column = 
    MAXX(FILTER(ALL('Table B'),'Table B'[Start Date]>=[InProgressDate] && 'Table B'[End Date]<=[SolvedDate]),[Phase])
  • ImkeF's avatar
    ImkeF
    8 years ago

    You can add column to your Table A like so:

     

    let
        Source = TableA,
        #"Added Custom" = Table.AddColumn(Source, "Custom", each Table.SelectRows(TableB, (tblB) => tblB[StartDate] <= _[InProgressDate] and tblB[EndDate] >= _[SolvedDate])),
        #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Phase"}, {"Phase"})
    in
        #"Expanded Custom"

    code in "Add-column"-dialogue: