Home > other >  If Statement in Power Query
If Statement in Power Query

Time:06-23

I have a simple if Statement in Power Query I feel I need a separate set of eyes on.

I am trying to say if the current day of the week is Monday then I want the system to display whatever the date was 3 days ago, else any other day just show yesterdays date. My formula below is receiving the error "Token RightParen expected." at the "Date" after "then" on the 2nd line.

 if(Date.DayOfWeek(DateTime.FixedLocalNow()) = 0 then
 Date.AddDays(Date.From(DateTime.FixedLocalNow()),-3) else
 Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1))

CodePudding user response:

A few extra characters. Remove first and last parenthesis

let Source =  if 
Date.DayOfWeek(DateTime.FixedLocalNow()) = 0 then
Date.AddDays(Date.From(DateTime.FixedLocalNow()),-3) else
Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1)
in Source
  • Related