DurationDays between two dates and Today if end is blank

Plukey

Board Regular
Joined
Apr 19, 2019
Messages
138
Office Version
  1. 2016
Platform
  1. Windows
I have two dates in power query Start & End Every column has a start date, but not every column has a finish date. I am trying to create a Custom column that has the number days of the record & if no end date use todays date Im unable to figure it out. Please help
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
This assumes two columns Start and End
l
Power Query:
et
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start", type date}, {"End", type date}}),
    #"Inserted Date Subtraction" = Table.AddColumn(#"Changed Type", "Subtraction", each if [End]= null then Duration.Days (Date.From(DateTime.LocalNow())- [Start]) else Duration.Days([End] - [Start]))
in
    #"Inserted Date Subtraction"

Book10
ABC
1StartEndSubtraction
27/7/20208/1/202025
38/16/20219/1/202116
49/28/202010/5/20207
510/1/202152
69/18/202165
78/19/20219/1/202113
84/20/20215/1/202111
93/16/20215/1/202146
109/23/202160
115/24/20216/5/202112
Table1
 
Upvote 0
Solution
Fantastic!!! You saved the day! Thank you so very much!
 
Upvote 0

Forum statistics

Threads
1,223,692
Messages
6,173,857
Members
452,535
Latest member
berdex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top