web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add Columns to collection
Power Apps
Answered

Add Columns to collection

(0) ShareShare
ReportReport
Posted on by 28

Good morning,

 

I am struggling to get the formula correct to add a column to a collection. I want to use the collection as the filter for a drop down elsewhere in the App, when the count of the item = 3, don't show the item. I can get this to work in a gallery, but get a delegation warning.

 

I have 2 SharePoint lists that I am using, 'Tooling List' and 'Tooling Booking List'. I have created 2 collections for those on the App OnStart.

colToolingSets = ClearCollect(colToolingSets, 'Tooling Sets');

and

colBookedOut = ClearCollect(colBookedOut, Filter('Tooling Booking List', OutIn = "Out"));
 
I want to add a column to colToolingSetsWithCount that counts the number of rows in colBookedOut where the Title values for each match.
e.g. Tooling set 100g Set 1 is listed 3 times in colBookedOut
However,  When I use the below code I get 12 for every record which is the total number of rows in the collection, I should only be getting a count of 3 for any Tooling Set. and based on current data, only 4 of the sets have that figure (hence 12, 3 x 4), the other 11 have 0 items booked out.
 
I have used the below to get that outcome, what am I missing..
 
ClearCollect(colToolingSetsWithCount, AddColumns(colToolingSets, "BookedOutCount", CountIf(colBookedOut,Title = Title)));
 
Thanks
Mike
Categories:
I have the same question (0)
  • v-mengmli-msft Profile Picture
    on at

    Hi @MikeBeman ,

     

    Please try this.

    ClearCollect(colToolingSetsWithCount, AddColumns(colToolingSets, "BookedOutCount", LookUp(AddColumns(GroupBy(colBookedOut,"Title","test"),"Count",CountRows(test)),Title=Title,Count)))

     

     

    Best regards,

    Rimmon

  • MikeBeman Profile Picture
    28 on at

    Hi Rimmon, 
    Thanks, this is better, but now I get 3 as the result for all items

  • Verified answer
    BhaskarDhone Profile Picture
    1,392 Super User 2025 Season 2 on at

    your code looks correct only thing is you have common field name hence system is getting confused.

    Try this.

     

    ClearCollect(colToolingSetsWithCount, AddColumns(colToolingSets As Table, "BookedOutCount", CountIf(colBookedOut,Title = Table.Title)));

     

     

  • MikeBeman Profile Picture
    28 on at

    Values I am expecting to seeValues I am expecting to seeWhat is in the collectionWhat is in the collection

  • MikeBeman Profile Picture
    28 on at

    @BhaskarDhone - this worked, thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard