Forum Discussion
Dax Week Calculation - Power BI
- 3 years ago
Hi RenanPNog ,
And why not using DATEDIFF with WEEK as interval?
I hardcoded the dates for demonstration purposes.
- RenanPNog3 years ago
Helper I
Hello, J.Payeras.
The reason is because if i bring week as argument, it won't return me the expected result, check it out:
Also, please, check my top comment, where i show expected weeknum result for each day.
Thanks in advance. - CBT_Dez2 years agoNew Member
Hi Payeras_BI,
I'm struggling with DAX Datediff week caculation,
power bi dax No. of weeks = datediff(date(2023,11,15), date(2023,11,28), week) correctly returned result as 2, why did my power bi desktop for this formula No. of weeks = datediff(date(2023,09,06), date(2023,11,28), week) returned result of 12 when it should be 11?
I used co-pilot trying to find solution, one of the suggestions was to use datevalue; and I changed the formula to
No. of weeks = datediff(DATEVALUE("2023-09-06"), datevalue("2023-11-28"), week)The returned result was still 12 instead of 11.Can you suggest what went wrong with the formula please?In order to get the correct result on my reports for now, I have changed it toNo. of weeks = INT(datediff(date(2023,09,06), date(2023,11,28), week))- CBT_Dez2 years agoNew MemberCorrection:In order to get the correct result on my reports for now, I have changed it toNo. of weeks = INT(datediff(date(2023,09,06), date(2023,11,28), day) / 7)