Forum Discussion

joshua1990's avatar
joshua1990
Post Prodigy
1 year ago
Solved

Filter on last row for each article

Hi experts! I have a weekly archive of our sales date, structured like this: Year-Week Article Team Country Department Group 2025-01 A A AAAA AA AAA 2025-02 A   AAAA AA   ...
  • Akash_Varuna's avatar
    1 year ago

    Hi joshua1990 Could you try this please 

    • Remove Unnecessary Columns:

      • Select master data columns and use Remove Other Columns.
    • Sort by Article and Year-Week:

      • Sort Article (ascending) and Year-Week (descending).
    • Group by Article:

      • Go to Home → Group By:
        • Group by Article and choose All Rows.
    • Keep the Latest Row:

      • Add a custom column with:
        Table.FirstN([All Data], 1)
      • Expand the table to show required fields.
    • Add "Last Entry" Column:

      • Create a column for Year-Week and rename it Last Entry.
        If this post helped please do give a kudos and accept this as a solution
        Thanks In Advance
  • PwerQueryKees's avatar
    1 year ago

    From

    Using

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year-Week", type date}, {"Article", type text}, {"Team", type text}, {"Country", type text}, {"Department", type text}, {"Group", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Article"}, {{"Rows", each Table.Last(_)}}),
        #"Expanded Rows" = Table.ExpandRecordColumn(#"Grouped Rows", "Rows", {"Year-Week", "Team", "Country", "Department", "Group"}, {"Year-Week", "Team", "Country", "Department", "Group"})
    in
        #"Expanded Rows"

    To

     

    Did I answer your question? Then please (also) mark my post as a solution and make it easier to find for others having a similar problem.
    Remember: You can mark multiple answers as a solution...
    If I helped you, please click on the Thumbs Up to give Kudos.

    Kees Stolker

    A big fan of Power Query and Excel

  • SundarRaj's avatar
    1 year ago

    Hi joshua1990 , here's a solution you could look at. In case of any clarifications or if I haven't got your query correctly, don't hesitate to correct me or ping back. I'll attach the image of the code below. Thanks!