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
Thank you very much
It's excellent!!! it worked perfectly (I just had to change the name of the [ID] column to the correct one that I got wrong)
Thanks again for your quick and assertive response.!!
Even so, I'm worried that the system really does take a long time to process everything... And I'm afraid that with daily updates the process will take too many time. Tests are needed.
One question: Is it possible to block the process in the Power Query editor, for example, from the last 3 months to the whole past (there's data going back to 2002) in order to save time processing lines since it won't change any more?
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.
- DBrito792 years agoFrequent Visitor
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