Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
tackytechtom
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➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

3 REPLIES 3
KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @inawab ,

 

You have elce instead of else in the formula

 

Regards

KT

tackytechtom
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➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors