Forum Discussion
PierreM52
5 years agoNew Member
IF THEN ELSE syntax
Hello all, I've a syntax issue, it returns me "THEN syntax is incorrect" My code : IF (HOUR(Production[Debut])>=5 && HOUR(Production[Debut])<13 && WEEKDAY(Production[Jour],2)<>5 ...
- 5 years ago
Hi PierreM52
Here's your if then else translated into M for Power Query
I've also created a PBIX file and an Excel Workbook with dummy data showing how this works.
#"Added Custom" = Table.AddColumn(PreviousStepName, "Custom", each if (Time.Hour([Debut]) >= 5 and Time.Hour([Debut]) < 13 and Date.DayOfWeek([Jour], Day.Monday) <> 5) then "Matin" else if (Time.Hour([Debut]) >= 3 and Time.Hour([Debut]) < 21 and Date.DayOfWeek([Jour], Day.Monday) <> 5) then "Après-midi" else if Date.DayOfWeek([Jour], Day.Monday) <> 5 then "Nuit" else if (Time.Hour([Debut]) >= 5 and Time.Hour([Debut]) < 11 and Date.DayOfWeek([Jour], Day.Monday) = 5) then "Matin" else if (Time.Hour([Debut]) >= 11 and Time.Hour([Debut]) < 17 and Date.DayOfWeek([Jour], Day.Monday) = 5) then "Après-midi" else "Nuit")Phil
If I answered your question please mark my post as the solution.
If you liked my answer click on the Thumbs Up icon.