Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

PowerBI Query

I would like to display only Max data from this below table in PowerQuery.   tried List.Max or List.Table . But not working. How to extract the max date and display in the same column itself?   ...
  • PhilipTreacy's avatar
    5 years ago

    Hi Anonymous 

    I'm not sure what you want the result to look like.  I don't know what you mean by extract the max date and display in the same column itself ?

    Do you want just a single value like this?

     

    Here's the code that generates this from your sample data and you can download this file with the code.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tcq5DQAgEAPBXogJbB9vLYj+24AE4XA1u1YCg4KQdr4hzR/hUgI/qktz6S7DY9pGmJAuerIP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Added Custom" = Table.AddColumn(Source, "Date", each Date.FromText(Text.Middle([Column1],4,4) & " " & Text.Start([Column1],2) & " " & Text.Middle([Column1],2,2), "en-US")),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1"}),
        #"Filtered Rows" = Table.SelectRows(#"Removed Columns", let latest = List.Max(#"Removed Columns"[Date]) in each [Date] = latest)
    in
        #"Filtered Rows"

    Regards

    Phil