Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Join/Merge not working properly

Hi there!   I need to get the most recent amount of the product.   I have my table:   ProductID    ProductName      Date          Amount 10070 City Bike 12/15/2015 45,876 10045 Grave...
  • PhilipTreacy's avatar
    5 years ago

    Hi Anonymous 

    What date format are you using? What date is 16/15/2015?

    The dates in the PBIX don't match the images above but no matter, the query still works.

    After doing the Group By Product ID on Max Date, treat the resulting table as your left table.

    Treat your (earlier) duplicated table with all your data as your right table.

    Then do a Left Outer Join matching the Date and Product ID columns to give you only 1 row per Product in your final table.

    Here's the PBIX file. 

    NOTE: The image below is from your PBIX data, so doesn't look the same as the images you posted.

    Regards

    Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.

  • wdx223_Daniel's avatar
    5 years ago

    let
        Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
        Custom1 = Table.FromRecords(Table.Group(Source,"ProductID",{"n",each Table.Sort(_,{"Date",1}){0}})[n])
    in
        Custom1