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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ClaireN
Frequent Visitor

Need day number to be different for different years

Hi everyone

I need to compare the numbers of samples arriving at a lab by day - and compare 2019 to 2020. But need the days of the week to line up - 

DayNoOfYear =
DATEDIFF ( DATE ( YEAR ( 'Table'[Date] ), 1, 1 ), 'Table'[Date], DAY ) + 1

that formula is all good, but I need day 1 of 2020 (a wednesday) to have the number 2 against it so that it matches with the first day Wednesday in 2019, which is a 2 (day 1 of 2019 is a Tuesday). 

Is it possible to modify that formula so that if year = 2020 I can make it be +2 at the end instead of +1 in my date table?

Hope all are well 

Claire

3 REPLIES 3
Greg_Deckler
Super User
Super User

Perhaps something like:

 

DATEDIFF ( DATE ( YEAR ( 'Table'[Date] ), 1, 1 ), 'Table'[Date], DAY ) + 1 + WEEKDAY('Table'[Date]) - WEEKDAY(DATE(YEAR('Table'[Date])-1,1,1))

 

Would likely need refinement.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

 

Hi Greg, thanks for your reply! I added the formula (day num of year V2) and its done something very curious! am trying to pull it apart to understand why its doing what its doing, as feel like this could be a solution !

DatesDates

 

This is probably a pretty hack solution, but I just did this: 

Day Number of Year 2 = IF('Dates'[Year] = 2020, 'Dates'[Day Number of year] +1, 'Dates 2019'[Day Number of year])
 
I have a column in the date table for the Year and another for the day number of year... it seems like there could be a way to do it, but times a bit limited as the boss wants the report - will have to think some more about it later! 
 
Hope everyone out there in Power BI land is doing ok with the COVID madness - this is such a super helpful community - hang in there people! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors