Results 1 to 1 of 1

Thread: PQ - Extract numbers from column with condition

  1. #1
    Sir Moderator sandy666's Avatar
    Join Date
    May 2018
    Posts
    239
    Rep Power
    7

    Cool PQ - Extract numbers from column with condition

    (question from the web)
    If cell contains "Cr" then remove "Cr" and multiply by -1
    Source Result
    raw Number
    100
    100
    200
    200
    300
    300
    400 Cr
    -400
    500
    500
    600
    600
    200 Cr
    -200

    Code:
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        Text = Table.TransformColumnTypes(Source,{{"raw", type text}}),
        Number = Table.AddColumn(Text, "Number", each try Number.From([raw]) otherwise Number.From(Text.Select([raw],{"0".."9"})) * -1),
        RC = Table.RemoveColumns(Number,{"raw"})
    in
        RC
    Last edited by sandy666; 02-16-2021 at 04:07 AM.
    sandy
    I know you know but I forgot my Crystal Ball and don't know what you know also I may not remember what I did weeks, months or years ago so answer asap. Thinking doesn't hurt

Similar Threads

  1. How to populate the column 3 under this condition??
    By raghuprabhu in forum Excel Help
    Replies: 11
    Last Post: 04-05-2019, 12:34 PM
  2. Extract numbers from text into multiple columns
    By Giraffe in forum Excel Help
    Replies: 17
    Last Post: 10-06-2015, 10:41 PM
  3. Extract Only Numbers & TEXT From Text String
    By mahmoud-lee in forum Excel Help
    Replies: 9
    Last Post: 11-02-2013, 02:49 PM
  4. Extract numbers from alphanumeric values
    By tushar.tarafdar in forum Excel Help
    Replies: 3
    Last Post: 09-20-2012, 10:16 PM
  5. VBA Function To Extract Decimal Numbers
    By PcMax in forum Excel Help
    Replies: 7
    Last Post: 11-19-2011, 09:42 PM

Posting Permissions

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