Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

using index columns to combine data from two tables

I need to combine data from two tables. Table A looks like this where Index Start and Index Stop map to Index in Table B.  Table B looks like this. The Index column lists only the values that...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I think you can add a custom column in Table A by this code in Power Query Editor.

    Index =
    
    {Number.From([Index Start])
    ..
    if 
    [Index End] = null 
    then
    List.Max(#"Table B"[Index]) 
    else 
    Number.From([Index End])}

     

    Then expand Index in Table A.

    And then merge Table A and Table B by Index columns.

    For reference: merge-queries-overview

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.