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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create OnSelect functi...
Power Apps
Answered

Create OnSelect function of a button that will count the total number of the same title in a list that is selected in the gallery

(0) ShareShare
ReportReport
Posted on by 29

I want to create OnSelect function of a button that will count the total number of the same title in a list that is selected in the gallery and put it into a notify function.
This is my list:

JasonJunio_3_0-1692706459255.png

And here is my gallery, the 'Request button' is the one that counts and has notify function:

JasonJunio_3_1-1692706529671.png

Here is my current code in the OnSelect property of my Request to Buy button:

If(
 !IsBlank(Contact_2) && !IsBlank(Name_2) && !IsBlank(Address_2), 
 ForAll(
 Gallery4_1.AllItems,
 Patch(
 Buyer_Information,
 Defaults(Buyer_Information),
 {
 Title: ThisRecord.Title,
 Total_Price:ThisRecord.Price,
 Buyer:Name_1.Text,
 Address: Address_1.Text,
 Contact_Number: Contact_1.Text,
 Date_and_time: DatePicker1.SelectedDate
 }
 )
 );
 Reset(Name_1);
 Reset(Address_1);
 Reset(Contact_1);
 Clear(colBuyItem);
 Notify("Successfully requested", NotificationType.Success, 5000),
 Notify("Please fill Name/Address/Contact #")
);
Categories:
I have the same question (0)
  • Verified answer
    Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @JasonJunio_3 

     

    Try this

     

    If(
    !IsBlank(Contact_2) && !IsBlank(Name_2) && !IsBlank(Address_2),
    // Calculate the total count of the same title in the gallery
    ClearCollect(
    colTitleCount,
    Filter(Gallery4_1.AllItems, Title = ThisRecord.Title)
    );
    // Perform the Patch operation
    ForAll(
    Gallery4_1.AllItems,
    Patch(
    Buyer_Information,
    Defaults(Buyer_Information),
    {
    Title: ThisRecord.Title,
    Total_Price: ThisRecord.Price,
    Buyer: Name_1.Text,
    Address: Address_1.Text,
    Contact_Number: Contact_1.Text,
    Date_and_time: DatePicker1.SelectedDate
    }
    )
    );
    Reset(Name_1);
    Reset(Address_1);
    Reset(Contact_1);
    Clear(colBuyItem);
    // Notify with the total count
    Notify(
    "Successfully requested. Total items with the same title: " & CountRows(colTitleCount),
    NotificationType.Success,
    5000
    ),
    Notify("Please fill Name/Address/Contact #")
    )

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard