Forum Discussion

trang_000's avatar
trang_000
New Member
1 year ago

Power Query | Error on merging 2 tables

Actual Case:

Table 1:

 - Original data:

PolNoTrannoIncDateExpDateEffDate
123451202412012024123120241201
123452202412012024123120241202
123453202412012025011520241203

 - Step 1: Add "Merged" column = PolNo+EffDate+Tranno

 - Step 2: Sort "Merged" desc

 - Step 3: Add "Merged.1" column = PolNo+IncDate

 - Step 4: Deduplicate "Merged.1"

 

Table 2:

- Original Data

PolNoEffDate
1234520241204

 

- Step 1: Merge Table 1 by PolNo

- Step 2: Expand Table1.IncDate and Table1.ExpDate

Actual Result

- Table1.ExpDate = 20241231

Expected Result:

- Table1.ExpDate = 20250115

3 Replies

  • What's your reason for sorting in step 2?

    Which columns are you deduplicating by in step 4?  Note that Power Query "Remove Duplicates"  is more often than not doing something different than what you expect.

    • trang_000's avatar
      trang_000
      New Member

      Thanks for your feedback.
      - Step 2 - 4: to get transaction has the max EffDate and max Tranno. 
      - Deduplicate means removing duplicate. I removed duplicate in column Merged.1 = PolNo + IncDate

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi trang_000 

    Can you provide some more sample data, the sample data you provide is relatively small that can't restore the expected results you want.

     

    Best Regards!

    Yolo Zhu