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 / Missing data in galler...
Power Apps
Unanswered

Missing data in gallery after Saving items using patch in Canvas App.

(0) ShareShare
ReportReport
Posted on by 23

Hello community, I am encountering an issue while showing data in a gallery. 

I have a SQL table that has around 6,000 rows. 

I am using ClearCollet to collect all rows as follows:

 

Screen OnVisible : 

ClearCollect(colMappingTable_Full, Filter(mapping_table, item_num<2000), Filter(mapping_table, item_num>2000 && item_num <4000),Filter(mapping_table, item_num>4000 && item_num <6000), Filter(mapping_table, item_num>6000 && item_num <8000),Filter(mapping_table, item_num>8000 && item_num <10000))
 
Gallery Items: 
SortByColumns(
    Filter(
        colMappingTable_Full,
        ((IsBlank(TextInput1.Text)) Or (Trim(TextInput1.Text) in contract_name) Or
        (Trim(TextInput1.Text) in mapping_item) Or
        (Trim(TextInput1.Text) in item_short_name) Or
        (Trim(TextInput1.Text) in status))
        && (IsEmpty(ComboBox2_Client.SelectedItems.Value) || Lower(client_name) in Lower(ComboBox2_Client.SelectedItems.Value))),
        "contract_name", SortOrder.Descending)
 
Patch: 
Patch(
    mapping_table, LookUp(mapping_table, id = Gallery3.Selected.id),
    {item_short_name: TextInput2.Text,
    status: ComboBox4.Selected.Value});
Notify("Item Short Name Updated successfully", NotificationType.Success);
ClearCollect(colMappingTable_Full, mapping_table);
This shows the exact Row count of the table. But, gallery items are dropping weirdly after I filter my data using ComboBox and save data using the Patch function. 
Total row count of the Gallery : jaipalambati_3-1705304357043.png

 

After using filters,

Row count before Saving Items: jaipalambati_1-1705303871310.png

Row Count after Saving items : jaipalambati_2-1705303894365.png

 

The row count is still 29 if I reselect the filters.  If I remove all the filters, the row count of the gallery drops to 2000 (I think this is where the issue is coming from).

 

Please share your ideas on this. TIA

 

 

Categories:
  • WarrenBelz Profile Picture
    156,738 Most Valuable Professional on at

    Hi @jaipalambati ,

    It is simply because at the end, you are doing this

    ClearCollect(
     colMappingTable_Full, 
     mapping_table
    );

    and only picking up the first 2,000 items of the table. An alternative (I also have some other suggestions here).
    Screen OnVisible - collect all records in Table

    Clear(colMappingTable_Full);
    With(
     {
     _Sets: 
     With(
     {
     _Limits: 
     With(
     {
     _Limit: 
     Sort(
     mapping_table,
     item_num,
     Descending
     )
     },
     RoundDown(
     First(_Limit).item_num / 2000,
     0
     ) + 1
     )
     },
     AddColumns(
     RenameColumns(
     Sequence(
     _Limits,
     0,
     2000
     ),
     "Value",
     "LowID"
     ),
     "HighID",
     LowID + 2000
     )
     )
     },
     ForAll(
     _Sets As _MaxMin,
     Collect(
     colMappingTable_Full,
     Filter(
     mapping_table,
     item_num > _MaxMin.LowID && item_num <= _MaxMin.HighID
     )
     )
     )
    );

    Your Gallery Items

    With(
     {_Text: TextInput1.Text},
     SortByColumns(
     Filter(
     colMappingTable_Full,
     (
     IsBlank(_Text) Or 
     _Text in contract_name Or
     _Text in mapping_item Or
     _Text in item_short_name Or
     _Text in status
     ) && 
     (
     Len(ComboBox2_Client.Selected.Value) = 0 || 
     Lower(client_name) in Lower(ComboBox2_Client.SelectedItems.Value)
     )
     ),
     "contract_name", 
     SortOrder.Descending
     )
    )

    and now the important part - Patch both the Table and the Collection (I am assuming here your Patch button is inside the Gallery)

    Patch(
     mapping_table, 
     LookUp(
     mapping_table, 
     id = ThisItem.id
     ),
     {
     item_short_name: TextInput2.Text,
     status: ComboBox4.Selected.Value
     }
    );
    Patch(
     colMappingTable_Full, 
     ThisItem,
     {
     item_short_name: TextInput2.Text,
     status: ComboBox4.Selected.Value
     }
    );
    Notify(
     "Item Short Name Updated successfully", 
     NotificationType.Success
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • jaipalambati Profile Picture
    23 on at

    @WarrenBelz  thank you for the replay. Still the same issue. Still, the gallery count drops to 2000  after saving item 😞

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard