cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tu22
Helper I
Helper I

Count empty rows in a gallery

tu22_0-1669291937639.png

I am trying to count empty rows in a gallery but it returns false when all rows are empty, what am i missing?

i also want to patch only the rows that have data to my source.

3 REPLIES 3
Sundeep_Malik
Super User
Super User

Hey @tu22 

 

This is my gallery:

 

Sundeep_Malik_0-1669294545943.png

 

To count the empty rows: 

I applied the following formula on a text label:

CountRows(

Filter(
DataSource,
IsBlank(ColumnName)
)

)

tu22
Helper I
Helper I

@Sundeep_Malik yes i tried this but it doesn't give me the desired output. as seen in the screenshot, the comments column is empty but it returns false instead of true.

first, i am trying to test for blank columns

then, i am trying to count how many rows in the gallery are blank

finally, i am trying to patch the non-blank rows to my datasource.

MarkBandR
Helper II
Helper II

Here are a couple of things to try:

1) try using IsBlankOrError() instead of IsBlank() to see if that gives you the desired results.

 

2) If you are using a Collection to populate your Gallery, then try the following:

  a) when you load your Source Collection, also create a copy called colEdit.

  b) add a new Column to the colEdit collection named "Updated" and set the default value to 0.

  c) for the OnChange event of your controls in the Gallery Template, use a Patch statement on the colEdit Collection to update the column/field that is changed and set the "Updated" column to 1.

  d) Assuming you have a button or something similar to kick off the row updates to your data source, filter the colEdit Collection using "Updated" = 1.

 

This should allow you to only update/patch your data source with the changes that have been made.

 

Assumptions: Your Source Collection has a unique identifier so that ThisItem.ID or something similar would be valid.

 

You might be wondering "why use two collections? Just added the Updated field to a single collection." In my use of Galleries and Collections, I have found that having a Source collection and an Edit Collection allows things to work as expected. If you Patch the Source Collection with updates, you sometimes end up with a Refresh on the Gallery with unintended results. Note: You can use a Collect statement on your Source and Edit Collection to add a new row/item and that does not cause a Refresh issue (for whatever reason).

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,533)