Forum Discussion
Getting Date from Week Number and Year
- 4 years ago
It's working well 🙂
Hey MH3 ,
your question is difficult to answer, as it is not clear how the columns are calculated.
Next to that, it's unusual that a fact table contains these columns, a fact table should only contain the SalesDate column, then this column will be connected to your date table.
The DAX statement below creates a table containing the information of three dates:
Table =
var Date1 = DATE( 2020 , 12 , 27 )
var Date2 = DATE( 2020 , 12 , 28 )
var Date3 = DATE( 2021 , 1 , 2 )
return
UNION(
ROW(
"date" , Date1 , "WeekNumber ISO" , WEEKNUM( Date1 , 21 ) //the parameter 21 returns the isoweeknumber
)
, ROW(
"date" , Date2 , "WeekNumber ISO" , WEEKNUM( Date2 , 21 ) //the parameter 21 returns the isoweeknumber
)
, ROW(
"date" , Date3 , "WeekNumber ISO" , WEEKNUM( Date3 , 21 ) //the parameter 21 returns the isoweeknumber
)
)​
Maybe that helps to understand what's going on.
Regards,
Tom
- MH34 years agoHelper V
Actually, The data was given on Week-Year basis
so I had splitted the week and year= (TheYear as number, TheWeek as number) as date => let //test //TheYear = 2018, //TheWeek = 1, // offsetToISO = Date.AddDays(#date(TheYear,1,1),-4), dayOfWeek = Date.DayOfWeek(offsetToISO, Day.Monday), offset = -dayOfWeek + (TheWeek * 7), isoWeekDate = Date.AddDays(offsetToISO, offset) in isoWeekDate
and the StartWeek I had calculated by this Function- TomMartens4 years agoSuper User
Hey MH3 ,
please take the time and create a pbix that contains sample data, including your M functions. Upload the pbix to onedrive or dropbox and share the link.
Regards,
Tom
- MH34 years agoHelper V
TomMartens I have sent you a private message kindly go through it.
- Syndicate_Admin4 years agoAdministrator
Hi
@Syndicate_Admin
This function worked for me to calculate StartWeek
Thanks!