how to remove specific characters in specific cells

iosiflupis

New Member
Joined
Jan 26, 2022
Messages
39
Office Version
  1. 365
Platform
  1. Windows
hello all (again),

I have a question. I am trying to construct a power query in excel. I can get most of what I want thru trial and error, youtube searching, and Google searching. However, I am stumped on a problem.

In the attached picture you can see 4 columns highlighted. the first two (departure) are what I currently have. The second two (arrival) are what I can now get to. What I need is to be able to remove the ":" from the blank cells. When I run a power query editor they show up as null. When I split, merge, and change the type to "Time" I get an error. The error appears when I change the type. What can I do to remove only the instances of the ":" in a blank cell?

Thank you.

P.S. if you know of a better way to convert a 4-digit number into 24 hr time without any errors I could use that instead of the long way I am doing it now.
 

Attachments

  • how to remove colons.png
    how to remove colons.png
    91.7 KB · Views: 11

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Result = Table.TransformColumns(Source, {{"Time", each Time.From(Text.PadStart(Text.From(_), 4, "0"))}})
in
    Result

Book2
ABCD
1TimeTime
2233911:39:00 PM
316514:51:00 PM
413041:04:00 PM
515443:44:00 PM
620488:48:00 PM
7105210:52:00 AM
82452:45:00 AM
94224:22:00 AM
10103910:39:00 AM
1115553:55:00 PM
126276:27:00 AM
138508:50:00 AM
145275:27:00 AM
155175:17:00 AM
16231111:11:00 PM
1713391:39:00 PM
1818416:41:00 PM
1913211:21:00 PM
2016474:47:00 PM
21115011:50:00 AM
2213141:14:00 PM
23103610:36:00 AM
2419047:04:00 PM
251112:11:00 AM
262102:10:00 AM
27
Sheet1
 
Upvote 0
I am not quite sure where to put this expression. I tried to edit the query in advanced editor but was receiving an error. then I tried to insert a column and couldn't get the expression to pass the error check.
 
Upvote 0
if you wanted to add a time formatted column use code similar to this:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Result = Table.AddColumn(Source, "TimeFormatted", each Time.From(Text.PadStart(Text.From(_[Time]), 4, "0")))
in
    Result
 
Upvote 0

Forum statistics

Threads
1,223,634
Messages
6,173,476
Members
452,516
Latest member
archcalx

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