Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I'm having difficulties calculating the number of days between two dates because I need the days to be counted for each seperate month. For example if the two dates are in the same month then it's easy.
Table.AddColumn(Source, "Subtraction", each Duration.Days([EndDate] - [StartDate])+1, Int64.Type)
But when the dates are in different months i need to calculate the days that fall in each month seperately.
Please see below a part of the two date columns
Thank you for your help!
@madlfc87 , Try using below m code
let
Source = ... , // Your data source
AddDateList = Table.AddColumn(Source, "DateList", each List.Dates([StartDate], Duration.Days([EndDate] - [StartDate]) + 1, #duration(1, 0, 0, 0))),
ExpandDateList = Table.ExpandListColumn(AddDateList, "DateList"),
AddYearMonth = Table.AddColumn(ExpandDateList, "YearMonth", each Date.Year([DateList]) * 100 + Date.Month([DateList]), Int64.Type),
GroupByYearMonth = Table.Group(AddYearMonth, {"YearMonth"}, {{"DaysInMonth", each Table.RowCount(_), Int64.Type}})
in
GroupByYearMonth
Proud to be a Super User! |
|
I will need to create this visualization so i would need a table with month, year, location, days
https://drive.google.com/file/d/1mY3Sh23MGMPULASau0uYKayL4OUwR10i/view?usp=drive_link
This is the file. Could you assist me? I didn't fully understand your code. If you want I will give you access. Thank you
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 |
|---|---|
| 92 | |
| 69 | |
| 50 | |
| 40 | |
| 38 |