+ Reply to Thread
Results 1 to 5 of 5

Power Query count occurrences of specific character in column

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Power Query count occurrences of specific character in column

    Hello all

    Im would like to add a column to a table, that counts the number of occurrences of the specific character | in another column, like this:
    CountOccurrencesInColumn.png


    As I understand from this post, I should be able to do this in by adding a calculated column with this:
    Please Login or Register  to view this content.
    But I cant figure out how to actually apply that - if I just write it in the Power Query M code it gives errors.

    How can I add this column in Power Query?

    Please note that I only have up to 2 occurrences in the sample, but in my actual setup I have more than 150 in some rows.

    Best regards
    Imbizile
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,933

    Re: Power Query count occurrences of specific character in column

    One way:

    Please Login or Register  to view this content.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Power Query count occurrences of specific character in column

    Add Custom column and use this formula

    = List.Count(Text.Split([All],"|"))-1
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,933

    Re: Power Query count occurrences of specific character in column

    I really MUST start using the various List commands in PQ!!! Nice one, Bo_Ry.

  5. #5
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Power Query count occurrences of specific character in column

    Very nice indeed, Bo_Ry!

    Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Power Query/Power Pivot Conditional Column creation & chart
    By mz_h in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-12-2020, 06:07 PM
  2. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  3. Custom Permutations Column in Power Query from two columns in the same Query
    By PaintPaddy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2019, 02:48 PM
  4. Remove Special Character within Power Query
    By excelnovice19 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-09-2019, 11:38 PM
  5. [SOLVED] Power Pivot does not load new column added in Power query
    By ibuhary in forum Excel General
    Replies: 12
    Last Post: 02-19-2019, 03:53 AM
  6. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  7. [SOLVED] Need Help: how to count occurrences of a text character in a range
    By leemanns in forum Excel General
    Replies: 7
    Last Post: 05-05-2012, 01:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1