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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Micgig
Frequent Visitor

Add day index based on year (considering leap years)

Hi everyone, hope you're having a good day.

 

I am writing as I'd like to create a column with an index based on year.

The column I have is the following (just showing few rows for example; data type "whole number"):

year_id
2019
...
2020
...
2021
2021
...
2022
2022

 

Every year has 365 records, namely 2020 repeats 365 times, 2021 repeats 365 times, ect. 

The years present in the column start from 2019 and arrive to 2022.

I would like to create a new column next to each year assigning a number, from 1 to 365, where the count restarts with a new year.

For example:

 

year_idindex
......
2021364
2021365
20221
......

 

The complication would be that 2020 is a leap year (and in the future there will be 2024 and so on, every 4 years).

Can anyone let me know how to that?

Thank you so much, wish you a good year

 

Michael

1 REPLY 1
amitchandak
Super User
Super User

@Micgig , Do you have date column, else add index column in power query

 

A new column in dax

countx(filter(Table, [Year] =earlier([year]) && [Date] <=([Date])),[Date])

 

Or use index in place of date

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Also, check

https://www.youtube.com/watch?v=7CqXdSEN2k4

 

 

You can also check dayofyear

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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