Forum Discussion
Get latest 7 days data to TABLE View
- 2 years ago
Hello Sandeep13,
try this solution:
let Source = YourExcelFile, Datetype = Table.TransformColumnTypes(Source,{{"Date", type date}, {"TOTAL_COUNT", Int64.Type}}), Filter = Table.SelectRows(Datetype, each [Date] >= Date.AddDays(List.Max(Datetype[Date]),- 6) and [Date] <= List.Max(Datetype[Date])) in FilterThe magic is in the Filter Step:
1. Get the max value of your [dates].2. Filter between max [dates] and max [dates] -7
Did I answer your question? Mark my post as a solution! - Anonymous2 years ago
Hi Sandeep13 ,
Thanks to ManuelBolz and Jaytam reply.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc27DcMwDIThXVhbgPg4kV4hQCYwVGSBdCmyfQLQDpX2w+G/4yBBuz/eTYw2gooP0Ny+PIoNLBHJvrCY6slRLAaxkbwv6z0Q2da+sLPDk3m9tJ9zu72eydx7z3KZXKZluMzK/CT85WjODw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, TOTAL_COUNT = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"TOTAL_COUNT", Int64.Type}}), #"SortedTable" = Table.Sort(#"Changed Type",{{"Date", Order.Ascending}}), #"rowCount" = Table.RowCount(#"SortedTable"), #"rowsToSkip" = if #"rowCount" > 7 then #"rowCount" - 7 else 0, #"lastSevenDays" = Table.Skip(#"SortedTable", #"rowsToSkip") in #"lastSevenDays"Final output
Best regards,
Albert HeIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Sandeep13 ,
Thanks to ManuelBolz and Jaytam reply.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc27DcMwDIThXVhbgPg4kV4hQCYwVGSBdCmyfQLQDpX2w+G/4yBBuz/eTYw2gooP0Ny+PIoNLBHJvrCY6slRLAaxkbwv6z0Q2da+sLPDk3m9tJ9zu72eydx7z3KZXKZluMzK/CT85WjODw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, TOTAL_COUNT = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"TOTAL_COUNT", Int64.Type}}),
#"SortedTable" = Table.Sort(#"Changed Type",{{"Date", Order.Ascending}}),
#"rowCount" = Table.RowCount(#"SortedTable"),
#"rowsToSkip" = if #"rowCount" > 7 then #"rowCount" - 7 else 0,
#"lastSevenDays" = Table.Skip(#"SortedTable", #"rowsToSkip")
in
#"lastSevenDays"
Final output
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi
It worked really well. you guys are awasome😊