Forum Discussion
M query help to generate data table with hourly rows in addition to existing table
Hi,
I have got below data as shown in image
To get above datatable, i have used below query
let
TodaysDate = Date.From(DateTimeZone.FixedUtcNow()),
Ranges = {
{"1D",
TodaysDate,
TodaysDate,
1},
{"WTD",
Date.From(Date.StartOfWeek(TodaysDate)),
TodaysDate,
2},
{"MTD",
Date.From(Date.StartOfMonth(TodaysDate)),
TodaysDate,
3},
{"QTD",
Date.From(Date.StartOfQuarter(TodaysDate)),
TodaysDate,
4},
{"YTD",
Date.From(Date.StartOfYear(TodaysDate)),
TodaysDate,
5},
{"1W",
Date.AddWeeks(TodaysDate,-1) + #duration(1,0,0,0),
TodaysDate,
6},
{"4W",
Date.AddMonths(TodaysDate,-1) + #duration(1,0,0,0),
TodaysDate,
7},
{"LY",
Date.AddYears(TodaysDate,-1) + #duration(1,0,0,0),
TodaysDate,
8}
},
GetTables = List.Transform(Ranges,
each CreatePeriodTable(_{0}, _{1}, _{2}, _{3})),
Output = Table.Combine(GetTables)
in
Output
Now the question, i have is i want to generate the file including all the hours starting form the first date in datatable. Similarly, the fist column must state whether it is part of 1D (one day) group, 1W (1 week) group & Month to date (MTD) , quarter to date QTD & year to date (YTD). I am using this to ultimately create a time slicer tile, based on which dashboard user will select the time. Another slicer which is not part of the details which i shared, will actually do the aggregation of the data, e.g day, week, month etc. I managed to get this sorted, but what i missed is Hour part, For single day selection, user want to see the data in hourly, which in current datatable wont possible,
Please help/guide me generate code in M query where the table contain 24 rows for every date & every group, so that i can club it when required. Hope i managed to explain my problem statement well. TIA
2 Replies
- Greg_Deckler
Community Champion
- ImkeF
Community Champion
Sorry, but I don't understand what you're after here. Could you please paste a link to a sample file with a sample of the desired input and output you're after? Also please paste code for function "CreatePerdiodTable".
Thanks.