Hi experts!
This is the formula I use to get the Week number in Excel, that takes 1-7 of every month as Week 1, then 8-14 as Week 2..and so on...It resets back to Week 1 once the next month starts.
="Week "&IF((QUOTIENT(DAY([@[Createdon Date]])-1,7)+1)>4,4,(QUOTIENT(DAY([@[Createdon Date]])-1,7)+1))
I am now trying to replicate this formula to add a custom column in Power Query using the below M code I used but I get an error. Any thoughts?
Error:
Expression.Error: We cannot convert the value #date(2022, 2, 8) to type Duration.
Details: Value=08-02-2022
Type=[Type]
This is the formula I use to get the Week number in Excel, that takes 1-7 of every month as Week 1, then 8-14 as Week 2..and so on...It resets back to Week 1 once the next month starts.
="Week "&IF((QUOTIENT(DAY([@[Createdon Date]])-1,7)+1)>4,4,(QUOTIENT(DAY([@[Createdon Date]])-1,7)+1))
I am now trying to replicate this formula to add a custom column in Power Query using the below M code I used but I get an error. Any thoughts?
Power Query:
Week =
"Week " & IF(
(INT(DATEDIFF(MIN(TableName[Createdon Date]), MIN(TableName[Createdon Date]), WEEK) % 4) + 1 > 4,
4,
(INT(DATEDIFF(MIN(TableName[Createdon Date]), MIN(TableName[Createdon Date]), WEEK) % 4) + 1)
)
Error:
Expression.Error: We cannot convert the value #date(2022, 2, 8) to type Duration.
Details: Value=08-02-2022
Type=[Type]