Forum Discussion
Einomi
3 years agoHelper V
Declare a variable in a step
Hi all, I have the following code to add the ISO week number based on my column date, which is called DateProduced AddWeekNo = Table.AddColumn(#"Colonnes renommées1", "Week No",
...
- 3 years ago
oh sorry about that the date at the end should be removed:
AddWeekNo = Table.AddColumn(#"Colonnes renommées1", "Week No", each let date = [DateProduced] in if Number.RoundDown((Date.DayOfYear(date)-(Date.DayOfWeek(date, Day.Sunday)+1)+10)/7)=0 then Number.RoundDown((Date.DayOfYear(#date(Date.Year(date)-1,12,31))-(Date.DayOfWeek(#date(Date.Year(date)-1,12,31), Day.Sunday)+1)+10)/7) else if etc....in fact you should be able to just add this almost anywhere:
let myVar = SomeCalculation in
artemus
3 years agoMicrosoft Employee
you can use let .. in anywhere e.g.
Table.AddColumn(Source, each
let
sum = [A] + [B],
calc = (sum - [A]) * (sum - [B])
in
calc)