• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Question regarding Exact match|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Question regarding Exact match|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryQuestion regarding Exact match
sp_PrintTopic sp_TopicIcon
Question regarding Exact match
Avatar
Peter Gulstad

Active Member
Members

Excel for Decision Making

Financial Modelling

Excel Analysis Toolpak

Excel

Word

Outlook

Excel Expert
Level 0
Forum Posts: 5
Member Since:
December 14, 2016
sp_UserOfflineSmall Offline
1
February 27, 2021 - 3:21 am
sp_Permalink sp_Print

Hi,

I download payment information from our bank system and now I am trying to retrieve the invoice numbers from this information.

I can get a list of invoice numbers from our ERP system and I am trying to use Philip Treacy's method from his blog post to get the information.

The received information includes a lot of reference numbers which I don't need, but these numbers may get flagged as a invoice number if I perform a partial match, therefore I would like to get an exact match. 

The problem with this is, that the information is not clean. The text column includes a lot of spaces which the TRIM function does not get rid of. Also, the customer may have put : or / before the invoice number. 

I have attached a small data set, where the solution only gets some of the invoice numbers, due to these issues. 

I am now lost as to how to get to the desired result. Maybe there is another way to retrieve numbers? If so, I know that my invoice number is always 6 digits long. 

Thanks in advance for any help.

Kind regards,
Peter Gulstad

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
March 1, 2021 - 8:55 am
sp_Permalink sp_Print

Hi Peter,

See file attached for solution.  The general approach with this is to split the text into sections using Text.Split.  This gives you a List of text strings.  You can then check for strings that are 6 characters long.  If you find one, try to convert it to a number.  If that fails then it was just text but if it succeeds then it is a number and that's your invoice number.

Of course this will only work if there are no other 6 digit numbers in the text string.  But with the string formats not being consistent, we have to start somewhere.

In order to split the strings I replaced certain characters with spaces, like : and /, which you mentioned customers sometimes insert.  There were also ASCII 160 characters (non-breaking space) that had to be replaced by a space.

let
    Source = Excel.CurrentWorkbook(){[Name="RawData"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Tekst", type text}, {"Beløb i DKK", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",":"," ",Replacer.ReplaceText,{"Tekst"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","/"," ",Replacer.ReplaceText,{"Tekst"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",Character.FromNumber(160)," ",Replacer.ReplaceText,{"Tekst"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value2", "Custom", each List.Sum(List.Transform(Text.Split([Tekst], " "), each if Text.Length(Text.Trim(_)) = 6 then try Number.From(_) otherwise 0 else 0)))
in
    #"Added Custom"

 

Regards

Phil

extstr.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage extstr.png (30 KB)
Avatar
Peter Gulstad

Active Member
Members

Excel for Decision Making

Financial Modelling

Excel Analysis Toolpak

Excel

Word

Outlook

Excel Expert
Level 0
Forum Posts: 5
Member Since:
December 14, 2016
sp_UserOfflineSmall Offline
3
March 2, 2021 - 6:46 am
sp_Permalink sp_Print

Hi Phil,

Thanks so much for your solution. It really takes care of most of the problems. However, now I have to lines that yields some unexpected results. I could not find out why, but I've realized the issue now. In lines 2 and 6, the invoice number is twice in the input, and the final output gives me the double value of the invoice number 🙂 Can we also account for that? 

Invoice numbers are currently in the series 21xxxx.

Thanks again.

Best regards,

Peter

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
March 3, 2021 - 2:59 pm
sp_Permalink sp_Print

Hi Peter,

Yes this situation can be dealt with.  The code creates a list of values that can be converted to a number.  If the value is text and can't be converted then we get a 0.  So you end up with a list like this

0

0

212981

0

212981

0

 

This list can be sorted 

212981

212981

0

0

0

0

 

Then you just take the first element in the list as the result - see attached file.

Regards

Phil

sp_AnswersTopicAnswer
Answers Post
Avatar
Peter Gulstad

Active Member
Members

Excel for Decision Making

Financial Modelling

Excel Analysis Toolpak

Excel

Word

Outlook

Excel Expert
Level 0
Forum Posts: 5
Member Since:
December 14, 2016
sp_UserOfflineSmall Offline
5
March 4, 2021 - 3:23 am
sp_Permalink sp_Print

Thank you so much, Phil! I really appreciate it!

Kind regards,
Peter

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
March 4, 2021 - 11:10 am
sp_Permalink sp_Print

no worries 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Kim Knox, Bhuwan Devkota
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Raj Mattoo
Mark Luke
terimeri dooriyan
Forum Stats:
Groups: 3
Forums: 24
Topics: 6221
Posts: 27285

 

Member Stats:
Guest Posters: 49
Members: 31909
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.