Results 1 to 11 of 11

Power Query custom function variable to make table a list

Threaded View

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

    Power Query custom function variable to make table a list

    I have the folloing custom function, but the last part [Units] I would like to put as a variable ,


    ( mytable as table, mycol as text ) => 
    let
        Custom1 = Table.AddColumn (  mytable , "NEW", (A)=>
    List.Last( 
      Table.SelectRows( mytable , (B)=> 
      Table.Column (B, mycol )  < Table.Column( A, mycol)  ) [Units]  )   )  
    in
        Custom1
    Just trying to add it 'toList' as text and then adding it directly does not work nor does TableColumn ,

     ( mytable as table, mycol as text, mylist as text  ) => 
    let
        Custom1 = Table.AddColumn (  mytable , "NEW", (A)=>
    List.Last( 
      Table.SelectRows( mytable , (B)=> 
      Table.Column (B, mycol )  < Table.Column( A, mycol)  ), Table.Column(mytable , mylist)  )   )  
    in
        Custom1
    Is there a way I can not have this part hardcoded. Attached workbook with several attempts.

    Richard.
    Attached Files Attached Files
    Last edited by Dicken; 07-08-2023 at 05:36 AM. Reason: Update attachment

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to update a custom function in Power Query
    By MangoFresh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-10-2023, 08:58 AM
  2. Power Query Custom function for running total
    By Dicken in forum Office 365
    Replies: 6
    Last Post: 10-29-2022, 10:58 AM
  3. Power query Custom function / parameter query
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 03-23-2022, 10:41 AM
  4. Replies: 1
    Last Post: 02-14-2022, 06:23 AM
  5. Power Query - Date List with changing variable
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2020, 12:27 PM
  6. Add custom fields to a table to simulate a pivot table - Power Query
    By nathalielesperance in forum Excel General
    Replies: 2
    Last Post: 10-25-2018, 06:44 AM
  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