Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
9 | |
7 | |
6 |