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 Experts , How can I split years between two dates using Dax or Power Query
| Start Date | End Date | Output |
| 01-01-2021 | 01-01-2023 | 2021, 2022, 2023 |
Using Power Query :
let
SplitYears = (StartDate, EndDate) =>
let
StartYear = Date.Year(StartDate),
EndYear = Date.Year(EndDate),
ListYears = {StartYear..EndYear},
Result = Table.FromList(ListYears, Splitter.SplitByNothing())
in
Result
in
SplitYears
Now you can use this function in your main query :
SplitYears([Start Date],[End Date])
Using DAX :
You can create a calculated table with the following DAX formula:
YearTable =
ADDCOLUMNS(
CALENDAR(
YEAR(MIN(Table[Start Date])),
YEAR(MAX(Table[End Date]))
),
"Year", YEAR([Date])
)
Then create a calculated column in your main table that concatenates the years for each row. You could use the CONCATENATEX function to do this :
YearList =
CALCULATE(
CONCATENATEX(
YearTable,
YearTable[Year],
", "
),
YearTable[Year] >= YEAR(Table[Start Date]),
YearTable[Year] <= YEAR(Table[End Date])
)
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 |
|---|---|
| 97 | |
| 70 | |
| 50 | |
| 42 | |
| 40 |