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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jon8930
Regular Visitor

Add Days/Time based on Condition Column

Hi,

 

I am fairly new to power query and I am having an issue with a sort of if function, in which i need a new column to return a date/time plus a few days/hours based of a condition in another column. Im not really sure how to set up the syntax and the column?

1 ACCEPTED SOLUTION

 

Yup, no problem.

Create a new custom column in Power Query with this structure:

if [Issue Type] = "Hardware" then [Created] + #duration(0, 4, 0, 0)  //four hours
else if [Issue Type] = "Software" then [Created] + #duration(4, 0, 0, 0)  //four days
else if [Issue Type] = "Remote Access" then [Created] + #duration(0, 0, 4, 0)  //four minutes
... etc.
else  // your escape value e.g. null, [Created]

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @Jon8930 ,

 

If you can provide a simple example of what your source data looks like and what your expected output looks like for each variable then this shouldn't be too difficult to sort for you.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




For example,

 

I would like a new column called SLA, to do the following:

(I am aware this an excel formula buts the best way can explain it)

each if [Issue Type] = "Hardware" then [CreatedDate] + I want it to add either a few hours or a few days.

Screenshot 2023-02-03 132608.pngScreenshot 2023-02-03 132628.png

The new columm i want to return the modified date/time dependant on the condition.

So if hardare add four hours etc.

 

Hope this makes sense.

 

 

Yup, no problem.

Create a new custom column in Power Query with this structure:

if [Issue Type] = "Hardware" then [Created] + #duration(0, 4, 0, 0)  //four hours
else if [Issue Type] = "Software" then [Created] + #duration(4, 0, 0, 0)  //four days
else if [Issue Type] = "Remote Access" then [Created] + #duration(0, 0, 4, 0)  //four minutes
... etc.
else  // your escape value e.g. null, [Created]

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors