Forum Discussion

dswinden's avatar
dswinden
Helper II
2 years ago
Solved

Transform Rolling Weeks Data To Only Filter To Max Date Per Source File

Hi Friends!   I know there are better ways to do this, but I am limited to my current methodology unless you have a better idea?   Summary of problem.  My data vendor sends me a file every week t...
  • Ritaf1983's avatar
    2 years ago

    Hi dswinden 
    you can add a conditional column that compares the week with the received :

    and filter out all those rows wich null :

    Result (the column test can be deleted)

    pbix is attached

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

     

  • ryan_mayu's avatar
    2 years ago

    maybe you can try this

     

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZBBCsUgDAXv4rqgpkkbz1K8/zV++ApN2hC7Gxgd5V1XggKY94xpGwi5gvCJmPrm6ibMcsjXcAi3crh6IDNpW2sc196r336Rn0zyiPb8ylff+3n+mp/8yAOFea29vPGL/J8Z+faYw3GsftWNDuMDWzOXw2GM9tr8rT2QCpp/rUahMK51WJ/MZ0m9/wA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Data file received" = _t, week = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data file received", type date}, {"week", type date}, {"Sales", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Data file received] =List.Min(#"Changed Type"[#"Data file received"]) or [Data file received]= [week] then 1 else 0),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
    in
    #"Removed Columns"

     

     

    pls see the attachment below