Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
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.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 5 | |
| 4 | |
| 3 |