+ Reply to Thread
Results 1 to 7 of 7

Power Query Custom function for running total

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

    Power Query Custom function for running total

    I've been trying to write a custom function in power query but keep getting errors, I've decided on a running total,

    so i can do that proved the column names are the the same ;


    Please Login or Register  to view this content.
    but this is no use if the column names are not 'unit' or whatever, so I tried the following for a percentage increase,

    Please Login or Register  to view this content.
    And I can select the query add colum; invoke custome function and put in whatever columns I need as current and prevoious, so thoght I should be able to do the same fort List.Sum( List.FirstN , the problem seems to be the source,
    I've tried ;


    Please Login or Register  to view this content.
    and uiing 'Any' then thpe 'Source' in as that parameter, but no good, any suggestion,I've attached the workbook with attemps and errors.

    Richard
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Power Query Custom function for running total

    FirstN takes 2 arguments, not 3. What are Start and Amount supposed to be in that call?
    Rory

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

    Re: Power Query Custom function for running total

    Yes, but you need the values as a list, so List.FirstN( Source [Values] , N value) , 3 , I tried using source within
    the function but it won't allow it, so I have to get the values to sum as a list.

    Richard.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Power Query Custom function for running total

    That doesn't answer my question though. You are passing three arguments to List.FirstN which won't work. What are Start and Amount supposed to be? Amount I can guess, but what is Start meant to be?

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Power Query Custom function for running total

    Surely all you want is:

    Please Login or Register  to view this content.
    then use it as:

    Please Login or Register  to view this content.

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

    Re: Power Query Custom function for running total

    Thanks,


    RD

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

    Re: Power Query Custom function for running total

    Quote Originally Posted by rorya View Post
    FirstN takes 2 arguments, not 3. What are Start and Amount supposed to be in that call?


    I' mistakenly deducted from reputation this was by accident, can a moderator reverse this.

    Richard.

+ 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 Bi running total and power pivot
    By Dicken in forum Office 365
    Replies: 1
    Last Post: 07-08-2022, 02:15 PM
  2. Power query Custom function / parameter query
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 03-23-2022, 10:41 AM
  3. Replies: 1
    Last Post: 02-14-2022, 06:23 AM
  4. [SOLVED] Running total in power query with criterion
    By Dicken in forum Office 365
    Replies: 6
    Last Post: 01-10-2022, 09:33 AM
  5. Replies: 1
    Last Post: 11-17-2021, 08:35 AM
  6. Power Query Grouped Running Total
    By sle7en in forum Excel General
    Replies: 2
    Last Post: 02-13-2021, 06:30 PM
  7. Power Query - Invoke Custom Function
    By leukep in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2017, 02:18 PM

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