+ Reply to Thread
Results 1 to 8 of 8

Power Query list replace / insert

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    758

    Power Query list replace / insert

    Hi,
    I have been trying to do a cumulative total , but it contains text ie { 1,2,3 , "A", 2,2,"X",4}

    I have tried replacing with a zero and then putting it back by using the position of the text values.

    so

    Please Login or Register  to view this content.
    but I need the first occurrence of "X" replaced by new{c} and the second by new {c + 1} , but of course "X" not longer occurs so i just get the first.
    I don't know if there is something similar to the splitter split by each ?

    I have included a solution, but it's not mine and I'm still working through how it all works so if anyone has other ideas I would be interested.

    Richard.
    Attached Files Attached Files
    Last edited by Dicken; 11-11-2024 at 04:13 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,883

    Re: Power Query list replace / insert

    There are many ways you could go about it - for example:

    Please Login or Register  to view this content.
    or something like:

    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    758

    Re: Power Query list replace / insert

    Thanks,

    I have not had a chance to go through the second method , I did not think of Accumulate, as I've been so focused on generate.

    your first is certainly a bit more straight forward than the versin i found, but it was useful as until then I did not know there was a Value.Is function.

    Richard.

  4. #4
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    758

    Re: Power Query list replace / insert

    Just as an aside I found that you can avoid having t use skip to get rid of leading 0 is to use an empty list and sum,


    Please Login or Register  to view this content.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,883

    Re: Power Query list replace / insert

    That list only has numbers in it...

  6. #6
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    758

    Re: Power Query list replace / insert

    was making a general point about not having to us skip,
    but with text ;

    Please Login or Register  to view this content.

    Richard
    Last edited by Dicken; 11-13-2024 at 09:41 AM. Reason: Correcting code

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,883

    Re: Power Query list replace / insert

    My point was just that the functions you were using in the previous one wouldn't get the right results with text in there, at least not without writing a custom comparer function.

  8. #8
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    758

    Re: Power Query list replace / insert

    Any way thanks for the help, it is a nice straight forward method, I still have to have a go with the second.

    RD

+ 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. Replies: 4
    Last Post: 06-02-2024, 07:54 AM
  2. Power Query try otherwise with text replace
    By Dicken in forum Office 365
    Replies: 3
    Last Post: 03-13-2024, 10:00 AM
  3. Replies: 5
    Last Post: 10-31-2023, 11:12 AM
  4. Replace formula using power query
    By Jclarka in forum Excel General
    Replies: 1
    Last Post: 09-12-2022, 06:42 PM
  5. [SOLVED] Replace duplicates with null by power query
    By siddiqsh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-20-2020, 04:38 AM
  6. [SOLVED] Append and replace in Power Query
    By punter in forum Excel General
    Replies: 3
    Last Post: 04-08-2020, 01:25 AM
  7. Power Query to replace macros
    By lynnsong986 in forum Excel General
    Replies: 9
    Last Post: 11-12-2019, 10:39 AM

Tags for this Thread

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