Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Duplicate Rows mutliple times basesd on Max Date for each Store ID

Hi, Hope you're safe and doing well! I'm trying to duplicate the max date row 4 times for each store ID. For example-  Max date for Store name A is 4/21/2022. Now I want to duplicate this r...
  • MFelix's avatar
    4 years ago

    Hi Anonymous ,

     

    In this case you need to use Power query and do the following:

     

    Duplicate the Query that you have and then add the following steps after your transformations:

    • Group by:
      • store_id
      • Max of Invoice date and all rows

     

    • Add a custom column with the following code:
    = Table.Max([ALL ROWS], "Index.INVOICE_DATE")
    • Expand the custom column (be aware to not select the store and the invoice date
    • Remove column ALL ROWS
    • On the other query append the previous query 4 times:

    • Disable the load from the AppendQuery

    See result attach.