cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
inawab
Frequent Visitor

Adding date to date with conditional

Hi Everyone

 

I want to add days to Date with condition if Value in column Shift = Night, but it gave error under Date.AddDays

 

IF [Shift] = "Night" then (Date.AddDays ([Date],1)) elce [Date]

 

inawab_0-1657802667311.png

 

Can someone Advice me what is wrong??

 

1 ACCEPTED SOLUTION
tomfox
Super User
Super User

Hi @inawab ,

 

Here my result:

tomfox_0-1657803173319.png

 

 

And here the code I used:

tomfox_1-1657803195774.png

 

if [Shift] = "night" then Date.AddDays([Date], 1) else [Date]

 

Hope this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
KT_Bsmart2gethe
Super User
Super User

Hi @inawab ,

 

You have elce instead of else in the formula

 

Regards

KT

tomfox
Super User
Super User

Hi @inawab ,

 

Here my result:

tomfox_0-1657803173319.png

 

 

And here the code I used:

tomfox_1-1657803195774.png

 

if [Shift] = "night" then Date.AddDays([Date], 1) else [Date]

 

Hope this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Greg_Deckler
Super User
Super User

@inawab Power Query is picky in its syntax, upper/lower case, spaces, etc. Try this:

if [Shift] = "Night" then Date.AddDays([Date],1) else [Date]

 

 


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 25

Ted's Dev Camp - August 25, 2022

Watch Session 25 of Ted's Dev Camp.

Top Kudoed Authors