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 / Adding 2 (unrelated) f...
Power Apps
Answered

Adding 2 (unrelated) formulas to a Gallery

(0) ShareShare
ReportReport
Posted on by 21

Hi, I've got a gallery set up which has 6 columns and about 100 rows. I want it to do 2 things: Every other row should have a background colour so it's easier to distinguish, and I want to place filters on it.

 

For the background colour thing I'm using the following formula:

 

 

ForAll(Sequence(CountRows('SharePoint File')), Patch(Last(FirstN('SharePoint File', Value)), {rowNumber:Value}))))

 

 

It gives each row a number, then in TemplateFill I use an if statement to give even numbers a different background colour.

 

For the filter I use the following formula:

 

 

Filter('SharePoint File', Country.Value = DropdownCountry.Selected.Value || DropdownCountry.Selected.Value = Blank(),
 Sector.Value = DropdownSector.Selected.Value || DropdownSector.Selected.Value = Blank())

 

 

 

When I use each of these formulas alone there's no problem, it works. But if I try to combine them with a semicolon in between, the whole DataGallery goes away. Can anyone explain to me how (if) I can use both of these unrelated formulas so that I can have the layout I want plus the filters?

 

Thanks in advance!

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @sweetpickleduck,

     

    You would use the Filter() statement as your datasource / input in the Row Number code. To avoid code repetition I would suggest using a With() function to store the Filter output in a function variable and reference that variable as the datasource. Inline comments are added to the code to further explain the functionality. 😊

     

    With(
     {
     //Save the Filter output to the function variable 'wFilter'
     wFilter: Filter(
     'SharePoint File', 
     Country.Value = DropdownCountry.Selected.Value || DropdownCountry.Selected.Value = Blank(),
     Sector.Value = DropdownSector.Selected.Value || DropdownSector.Selected.Value = Blank()
     )
     },
     //Add row numbers for alternating TemplateFill colors
     ForAll(
     Sequence(
     //wFilter servers as the input
     CountRows(wFilter)
     ), 
     Patch(
     //wFilter servers as the input - Index is preferred over Last(FirstN())
     Index(wFilter, Value), 
     {rowNumber:Value}
     )
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • sweetpickleduck Profile Picture
    21 on at

    It worked! Thank you so much!

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 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard