Extract strings after a search

rmbmw

New Member
Joined
Mar 17, 2022
Messages
5
Office Version
  1. 365
I have a power query that imports some emails into a specific folder. Now In the text body, there is some specific information I want to extract to a column. For example, a text contains "Duration:" After that, the duration is random. So I want to let's say "Duration" plus the specific text 24 strings. What is after that specific text? the "duration" text is unique but is not static meaning is no always in the same location of the text

The column will equal Duration: 0 Hours 24 Minutes 25 Seconds, for example, and so on.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
like that ?
1660926645113.png
 
Upvote 0
Yes, but remember, the duration is not always the same and is not always in the exact location. So I cannot split it by delimiter, it needs to be something more dynamic
 
Upvote 0
Yes, but remember, the duration is not always the same and is not always in the exact location. So I cannot split it by delimiter, it needs to be something more dynamic
Could you share example with all posibilty
 
Upvote 0
There are only two possibilities. Here it is. I removed actual information, but you'll get the idea. as you can see, sometimes it comes with the location

Example 1:

Ticket Number: (Ticket Number here)

Issue: Issue goes here

Start Time: 08/21/22 23:15:04

Location: location goes here

Duration: 16 hours 21 minutes 53 seconds

Call Volume: 0

Incident Owner: Incident owner

Incident Manager: manager

Root Cause: root cause

Associated Maintenance: associated maintenance


Example 2:


Ticket Number: (Ticket Number here)

Issue: Issue goes here

Start Time: 08/21/22 16:29:12

Duration: 23 hours 4 minutes 44 seconds

Call Volume: 0

Incident Owner: Incident owner

Incident Manager: manager

Root Cause: root cause

Associated Maintenance: associated maintenance
 
Upvote 0
The way you are putting it is easy; that text is part of only one cell, I'm trying to extract it individually

1661260855346.png
 
Upvote 0
Can you post your sample using XL2BB as we cannot manipulate data in a picture. Provide several samples as you indicated that the duration is not always in the same location. 5-10 records should suffice.
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    tbl  = Table.TransformColumns(Source, {{"Column1", each Text.Split(_, Character.FromNumber(10))}}),
    tbl1 = Table.TransformColumns(tbl, {{"Column1", each Text.Replace(List.Select(_, (x)=> Text.StartsWith(x,"Duration:")){0}, "Duration: ", "")}})
in 
    tbl1

or

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    tbl  = Table.TransformColumns(Source, {{"Column1", each Text.Split(_, Character.FromNumber(10))}}),
    tbl1 = Table.TransformColumns(tbl, {{"Column1", each Text.Replace(List.Select(_, (x)=> Text.StartsWith(x,"Duration:")){0}, "Duration: ", "")}}),
    tbl2 = Table.SplitColumn(tbl1, "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Hours", "Column1.2", "Minutes", "Column1.4", "Seconds", "Column1.6"}),
    tbl3 = Table.RemoveColumns(tbl2,{"Column1.2", "Column1.4", "Column1.6"})
in 
    tbl3

Book1
ABCDEFGHIJKL
2ATicket Number: (Ticket Number here) Issue: Issue goes here Start Time: 08/21/22 23:15:04 Location: location goes here Duration: 16 hours 21 minutes 53 seconds Call Volume: 0 Incident Owner: Incident owner Incident Manager: manager Root Cause: root cause Associated Maintenance: associated maintenance
3BExample 2: Ticket Number: (Ticket Number here) Issue: Issue goes here Start Time: 08/21/22 16:29:12 Duration: 23 hours 4 minutes 44 seconds Call Volume: 0 Incident Owner: Incident owner Incident Manager: manager Root Cause: root cause Associated Maintenance: associated maintenance
4
5ItemColumn1ItemHoursMinutesSeconds
6A16 hours 21 minutes 53 secondsA162153
7B23 hours 4 minutes 44 secondsB23444
8
Sheet4
 
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