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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
SonaSinghA
Helper III
Helper III

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors