Results 1 to 4 of 4

Thread: Sum only numeric columns with PQ

  1. #1
    Acolyte Nick Burns's Avatar
    Join Date
    May 2017
    Posts
    47
    Articles
    0
    Excel Version
    Office 365

    Sum only numeric columns with PQ



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Digging up this old thread - is there a way to total only columns that are numeric?

    With this:
    = Table.AddColumn(YourPreviousStep, "Sum", each List.Sum(Record.ToList(_)))

    I get an error as some of my columns are text.
    Oh... by the way, YOU'RE WELCOME!

  2. #2
    Acolyte Bill Szysz's Avatar
    Join Date
    Apr 2016
    Location
    Poznań, Poland Dublin, Ireland
    Posts
    95
    Articles
    0
    Excel Version
    Excel 365
    No problem, Nick :-))
    = Table.AddColumn(YourPreviousStep, "Sum", each List.Sum(List.Transform(Record.ToList(_), each if _ is number then _ else null)))
    first _ is different than second _ :-)))

  3. #3
    Administrator Pecoflyer's Avatar
    Join Date
    Oct 2011
    Location
    Brussels Belgium
    Posts
    1,656
    Articles
    0
    Excel Version
    2010 on Xubuntu
    @Nick


    Please do not hijack existing threads but rather create a new one with eventually a link to any threads of interest. Older threads are not always visited by the members, and, as most of us look at thread titles to see if they can help, you might be depriving yourself, and other members of valuable help.

    I created a new thread for you this time
    Last edited by Pecoflyer; 2019-06-20 at 07:31 AM.
    Thank you Ken for this secure forum.

  4. #4
    Acolyte Nick Burns's Avatar
    Join Date
    May 2017
    Posts
    47
    Articles
    0
    Excel Version
    Office 365
    Thanks Bill! Worked like a charm.

    Pecoflyer - will do! I always search the forum in case my question has already been asked and figured my question was somewhat related to the other thread that I would just tag on to it.
    Oh... by the way, YOU'RE WELCOME!

Posting Permissions

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