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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ggyczew
Advocate I
Advocate I

DATEDIFF no option for WEEK interval starting on MONDAY

As mentioned in topic there is no option for setting value to treat Monday as first day of week in DATEDIFF formula. As a result We get wrong DIFF for week range dates. There should be option for global setting.

1 ACCEPTED SOLUTION

Hi @ggyczew ,

This seems by design and can't be changed in the function, you can only get the expected result by the formula.

This also works:

"OffsetWeek", DATEDIFF(TODAY(), [Date]-1, WEEK)

Best Regards,
Community Support Team _ kalyj

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

8 REPLIES 8
v-yanjiang-msft
Community Support
Community Support

Hi @ggyczew ,

Is your problem solved?? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team _ kalyj

ggyczew
Advocate I
Advocate I

Not elegant solution for shifting result values

"OffsetWeek", DATEDIFF(TODAY(), [Date], WEEK) - IF(WEEKDAY([Date],2)<7,0,1)

 

Hi @ggyczew ,

This seems by design and can't be changed in the function, you can only get the expected result by the formula.

This also works:

"OffsetWeek", DATEDIFF(TODAY(), [Date]-1, WEEK)

Best Regards,
Community Support Team _ kalyj

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

If there is no such functionality in the DATEDIFF function, solution should be at least described in the documentation which also is translated with major errors in Polish version. 

Function documentation suggests that one can use intervals names like DZIEŃ, TYDZIEŃ, MIESIĄC.

This is misleading.

Hi @ggyczew ,

Sorry for the bad experience, do you mean this part in the document.

vkalyjmsft_0-1654068673975.png

Best Regards,
Community Support Team _ kalyj

ggyczew
Advocate I
Advocate I

Usage for Offset is in relative selection last X weeks, X Months etc. It is simple and works perfectly

ggyczew
Advocate I
Advocate I

In my country Poland week starts on Monday. There is setting in the WEEKDAY but there is no such in the  DATEDIFF with WEEK interval.

There are two option

1) global setting which would provide context for such functions.

2) localized paramaters which would translate to proper function result. On the translated version DATEDIFF, funkcja (DAX) - DAX | Microsoft Docs Microsoft suggests that Polish users can use as parameters localized text like TYDZIEŃ (=WEEK). This does not work.

 

 

EVALUATE
ADDCOLUMNS(
    CALENDAR(DATE (2022, 5, 1), DATE (2022, 5, 22)),
    "WeekNum", WEEKNUM([Date],2),
    "DayOfWeek", WEEKDAY([Date],2),
    "OffsetWeek", DATEDIFF(TODAY(), [Date], WEEK)
)

ggyczew_1-1652944720687.png

 

 

selimovd
Super User
Super User

Hey @ggyczew ,

 

DATEDIFF returns the numbers of hours/days/weeks, etc. between two dates.

I don't understand where exaclty you want to use Monday now?

 

Best regards

Denis

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.