Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dax Help to split years between two dates using Dax or Power Query

Hi Experts , How can I split years between two dates using Dax or Power Query

 

Start DateEnd DateOutput
 01-01-2021 01-01-2023 2021, 2022, 2023
   
1 REPLY 1
AmiraBedh
Super User
Super User

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  : 

Spoiler
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])
    )

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors