Extracting from Column - Better way?

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I am trying to pull the first character and then the first character after a delimitator - then concatenate those two. Is there a better more efficient way then doing all these steps? This is Power Query

let
Source = CostSourceData,
#"Removed Other Columns" = Table.SelectColumns(Source,{"ID", "Vendor", "[MF] Created by"}),
#"Duplicated Column" = Table.DuplicateColumn(#"Removed Other Columns", "[MF] Created by", "[MF] Created by - Copy"),
#"Inserted First Characters" = Table.AddColumn(#"Duplicated Column", "First Characters", each Text.Start([#"[MF] Created by - Copy"], 1), type text),
#"Inserted Text After Delimiter" = Table.AddColumn(#"Inserted First Characters", "Text After Delimiter", each Text.AfterDelimiter([#"[MF] Created by - Copy"], "."), type text),
#"Inserted First Characters1" = Table.AddColumn(#"Inserted Text After Delimiter", "First Characters.1", each Text.Start([Text After Delimiter], 1), type text),
#"Added Custom1" = Table.AddColumn(#"Inserted First Characters1", "UserID", each [First Characters]&[First Characters.1]),
#"Added Custom" = Table.AddColumn(#"Added Custom1", "File Name", each [ID] &"-"&[Vendor]&"-"&[UserID]),
#"Removed Other Columns1" = Table.SelectColumns(#"Added Custom",{"File Name"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Other Columns1")
in
#"Removed Duplicates"
#"Removed Duplicates"
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You could do something like:

Power Query:
let
Source = CostSourceData,
#"Removed Other Columns" = Table.SelectColumns(Source,{"ID", "Vendor", "[MF] Created by"}),
GetInitials = Table.AddColumn(#"Removed Other Columns", "Initials", each Text.Start([#"[MF] Created by"], 1) & Text.Start(Text.AfterDelimiter([#"[MF] Created by"], "."), 1), type text),
#"Added Custom" = Table.AddColumn(GetInitials, "File Name", each [ID] &"-"&[Vendor]&"-"&[Initials]),
#"Removed Other Columns1" = Table.SelectColumns(#"Added Custom",{"File Name"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Other Columns1")
in
#"Removed Duplicates"
 
Upvote 0
Solution
Another way:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UserIDs = List.Transform(Source[#"[MF] Created by"], each Text.Start(_,1) & Text.Start(Text.AfterDelimiter(_, "-"),1)),
    FileNames = List.Distinct(List.Transform(List.Zip({Source[ID],Source[Vendor],UserIDs}),each Text.Combine(_,"-"))),
    Result = Table.FromColumns({FileNames}, {"File Name"})
in
    Result

Book1
ABCDEFGHIJK
1IDVendor[MF] Created byCol1Col2Col3Col4Col5File Name
2AV1MMMMM-AAAA181314722A-V1-MA
3BV2NNNNN-BBB161232512B-V2-NB
4CV3OOO-CCCC19620105C-V3-OC
5DV4PP-DD24815213D-V4-PD
6EV5QQQ-E1749211E-V5-QE
7AV1MMMMM-AAAA10520334
8
Sheet1
 
Upvote 0
Thank you both. Each works. Very much appreciate the help and training
 
Upvote 0

Forum statistics

Threads
1,223,677
Messages
6,173,791
Members
452,534
Latest member
autodiscreet

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