cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smpa01
Super User
Super User

Built in PQ function to add items at the end of the list?

Is there any PQ built in functionality that adds an item to the end of the list?

To elaborate, my initial list is following = {{1,2,3},{"A","B","C"}}

I want to add {1} at the end of the above list, I can currently do that by

 

let
    Source = {{1,2,3},{"A","B","C"}},
    Custom1 = List.InsertRange(Source,List.Count(Source),{1})
in
    Custom1

 

But, I want to avoid writing Custom1 if there is a built-in functionality, something like following 

 

let
    Source = {{1,2,3},{"A","B","C"}},
    Custom1 = List.addAtTheEnd(Source,{1})
in
    Custom1

 

where the function figures out where to add the item by iteslf on the funtion call itself rather then me pointing it at the index position in 

List.InsertRange(<list>, <index>, <values>)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


1 ACCEPTED SOLUTION
Vera_33
Super User
Super User

Hi @smpa01 

 

I don't see a built-in one, but you can write one custom function like this

 

Vera_33_0-1635314888017.png

let
    Source = {{1,2,3},{"A","B","C"}},
    fxListaddAtTheEnd = (SourceList,newValue)=>List.InsertRange(SourceList,List.Count(SourceList),newValue),
    Custom1 = fxListaddAtTheEnd(Source,{1})
in
    Custom1

View solution in original post

1 REPLY 1
Vera_33
Super User
Super User

Hi @smpa01 

 

I don't see a built-in one, but you can write one custom function like this

 

Vera_33_0-1635314888017.png

let
    Source = {{1,2,3},{"A","B","C"}},
    fxListaddAtTheEnd = (SourceList,newValue)=>List.InsertRange(SourceList,List.Count(SourceList),newValue),
    Custom1 = fxListaddAtTheEnd(Source,{1})
in
    Custom1

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors