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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
abeirne
Helper II
Helper II

Indexing dates of the year

Hi, I would like to index the dates of each year (2019, 2020, 2021) so that I can match the index to the previous year's date.

So 2019 would have the index on the dates, and then I could match the 2020 index to the 2019 dates. Kind of like SamePeriodLastYear, but I am not able to use this with my current data, as the original ID's are all different throughout the years. Please help, I can explain more if needed. I am looking at quotes sent throughout the years, and would like to compare then YoY, but cannot do so without being able to connect the quotes to a primary key. I was thinking the index would become the primary key. Thank you in advance.

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

I am not sure if I follow, what you are describing would be day of year? You can get day of year with this calculated column dax: 

DayOfYear = DATEDIFF(STARTOFYEAR('Calendar'[Date]),'Calendar'[Date],DAY)+1

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

I am not sure if I follow, what you are describing would be day of year? You can get day of year with this calculated column dax: 

DayOfYear = DATEDIFF(STARTOFYEAR('Calendar'[Date]),'Calendar'[Date],DAY)+1

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you! Will this work year over year? So I would like a 1-365 from 2019, but also 1-365 to 2020, and so on. Would I need seperate date tables for this?

You would need separated table or some other logic to address leap years. The problem is that leap years will have numbers from 1-366. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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