Forum Discussion
Faster M needed
- 10 years ago
Hi Maxim :-)
Are you sure that this will prevent the multiple calls to the SALES-table?
To be on the safe side here it would look like this:
SalesDate = List.Buffer(SALES[DATE]), LMinSD = List.Min(SalesDate), LMaxSD = List.Max(SalesDate), #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each [DATE] >= LMinSD and [DATE] <= LMaxSD)
Hello,
I'm also trying to use the List.Buffer function for a very similar task and borrowed heavily from this example.
I have dates in my source data up to 4/30/2017 however the List.Max is returning 12/31/2016 rather than the latest date.
My souce is a .csv file so I guess it's treating them as text and not sorting them numerically? Also noteworth is that when the list is sorted decending 12/31/16 appears as the latest despite later dates being present in the list.
The dates are in column 32 of my .csv which "Last Sold Date" is the header/first row. Without removing the title it was being returned with the List.Max function instead of the 12/31/16 so I removed it.
let
LastSold = List.Buffer(#"Imported CSV"[Column32]),
#"Removed Items" = List.RemoveMatchingItems(LastSold,{"Last Sold Date"}),
LsMax = List.Max(LastSold),
Any help would be appreciated.
Yes, your dates recognized as a text.
You can transform them to the dates by several techniques:
1. Use Date.From function, where the second argument is "en-US"
2. Apply "Change type with locale" using UI - right click on the column, change with locale, then select date type and US locale (or via type assign button, to the left of the column name)
It should works.
BTW, you can promote first row to the column names instead of filtering it out