Forum Discussion
Help making an inventory calendar table in Power query Editor in M
- 2 years ago
You can try adding this query. You will need to adjust the start date of the 'List.Dates' step (currently Dec 1, 2023) along with the number of days you want in the table (currently 180).
let Source = List.Dates( #date(2023,12,01), 180, #duration(1,0,0,0) ), convertDatesToTable = Table.FromList( Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error ), changeToDateType = Table.TransformColumnTypes( convertDatesToTable, {{"Column1", type date}} ), renameColumn = Table.RenameColumns( changeToDateType, {{"Column1", "Date"}} ), addDailyEntries = Table.AddColumn( renameColumn, "dailyEntries", (x)=>List.Count(Table.SelectRows(SOWS, each [EntryDate] = x[Date])[ID] ), Int64.Type ), addDailyOuts = Table.AddColumn( addDailyEntries, "dailyOuts", (x)=>List.Count(Table.SelectRows(SOWS, each [OutDate] = x[Date])[ID]), Int64.Type ), addCumulativeIns = Table.AddColumn( addDailyOuts, "cumulativeIns", (x)=>List.Count(Table.SelectRows(SOWS, each [EntryDate] <= x[Date])[ID]), Int64.Type ), addCumulativeOuts = Table.AddColumn( addCumulativeIns, "cumulativeOuts", (x)=>List.Count(Table.SelectRows(SOWS, each [OutDate] <= x[Date])[ID]), Int64.Type ), addInventory = Table.AddColumn( addCumulativeOuts, "Inventory", each [cumulativeIns] - [cumulativeOuts], Int64.Type ) in addInventory
Without understanding the source of your data, the only suggestion I could give you would be to create a 'sowsInventory' query for each historic year (or groups of historic years). Run the query to get the values and then set the query to not be included in the report refresh and to not load into the report.
You would require a query that is included in the report refresh for the current year. This approach would require you to create a 'sowsInventoryTotal' query where you use Table.Combine to bring in all the historic and current queries. This should run 'quicker' but I am not sure that I would use the term 'fast'.
Hope this helps.
Thanks! I understood perfectly! That will help, and it will work for sure.
I make a query for the lasts years and one for this year and the previous year!
Thanks again for your suggestion!
Regards