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
MAkiva1
Helper I
Helper I

Day number of year (DAX)

I'm trying to generate a value that shows the current day number of the calendar year.  For instance, today is January 15, and I would like the measure to display the number 15.  I'd like for this to auto-update each day, so for January 16, it displays 16 and so on.

 

Is there a way to do this without creating a calculated column

 

Purpose: what I am trying to do is breakdown an annual goal into a YTD goal (i.e. if the 2018 goal is to create 1,000 widgets, then by the 15th day of the year, we should have created 41 widgets -- (1,000 / 365) * DayofYear (15) = 41.

 

Thanks,

1 ACCEPTED SOLUTION

Hi @MAkiva1,

 

The second parameter can be today(). 

Measure 4 =
DATEDIFF ( DATE ( 2018, 1, 1 ), TODAY (), DAY )

It's accurate if you use it locally. One possible effect is the time lag. But usually it won't be a problem.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anthonywork247
New Member

The answer is much simpler but requires 2 columns

First the Equation then the Explination

Col1 CurrentYearStartDate ="01/01/"&FORMAT(tbl_Date[Date],"YYYY") ---formatting ribon Data Type [Date] Format [dd/mm/yyyy]

Col2 YearDateNu = tbl_Date[Date]-tbl_Date[DayNu]+1 ---formatting ribon Data Type [Decimal Number] Format [General]

 

Explination

  1. Attain the Year in which the Date Occurs
  2. then add in the Start Day and Month, this gives you the starting date of the year
  3. Create a decimal column that subtracts the current date from the starting year date

Might be a bit of a long way of doing it but the result is 100%, please check and let me know

 

 

AlexAlberga727
Resolver II
Resolver II

Hey Folks -

 

I was looking for a solution to the same issues as the OP presented, and stumbled across this post.

 

I did not like the fact the solution was to hard code the year 2018 - As I wanted this to be added to my DateTable.

 

A solution I formed by slightly modifying the solution within this post was the following - 

 

DayNum of Year = 

DATEDIFF( DATE( YEAR(dDateTable[Date]),1,1), dDateTable[Date] , DAY ) + 1

 

Replace dDateTable[Date] with your date column within your date table. Now you should be able to compare YoY by Day of Year dynamically.

This is the correct answer. High Five, @AlexAlberga727

MAkiva1
Helper I
Helper I

I've found a potential solution, but don't know if it will produce accurate results (morning vs afternoon):

 

DayofYear = DATEDIFF(DATE(2018,1,1),DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())),DAY)

 

Any suggestions?

Hi @MAkiva1,

 

The second parameter can be today(). 

Measure 4 =
DATEDIFF ( DATE ( 2018, 1, 1 ), TODAY (), DAY )

It's accurate if you use it locally. One possible effect is the time lag. But usually it won't be a problem.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @MAkiva1,

 

Could you please mark the proper answer as solution?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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 Solution Authors