cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WebPortal
Post Prodigy
Post Prodigy

Is it possible to fill the rows of a gallery with alternate colors?

Is it possible to fill the rows of a gallery with alternate colors?

 

I've tried the following to the "Fill" property of my gallery:

 

If(Mod(Value(ThisItem.ID);2)=0; Color!Aqua; Color!AliceBlue)

But it's not working (returns a single color for the whole gallery).

 

My data source has an ID column 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@WebPortal 

You could use a DATEDIFF formula that counts the number of days since the epoch and determines whether they are divisible by two.

If(Mod(DateDiff(Date(1970,1,1),ThisItem.Date),2)=0, Color!Aqua; Color!AliceBlue)

 

Alternately, I have a method of adding row numbers to Collections that can be found in my free Collections Cookbook app:

https://powerusers.microsoft.com/t5/Community-App-Samples/Collections-Cookbook-50-Visual-Examples-am...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
mdevaney
Super User
Super User

@WebPortal 

Right idea,  wrong property.  Put your code in the TemplateFill property instead.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."  

eka24
Super User
Super User

Have you tried removing the Value:

If(Mod(ThisItem.ID);2=0; Green;Blue)

Also is your ID Column Unique

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

@mdevaney 

 

That works!

However, I now realize the gallery is ordered by date, thus the ID is not the right criteria to use for the colors.

It should be he order number, somehow. Is it possible?

mdevaney
Super User
Super User

@WebPortal 

You could use a DATEDIFF formula that counts the number of days since the epoch and determines whether they are divisible by two.

If(Mod(DateDiff(Date(1970,1,1),ThisItem.Date),2)=0, Color!Aqua; Color!AliceBlue)

 

Alternately, I have a method of adding row numbers to Collections that can be found in my free Collections Cookbook app:

https://powerusers.microsoft.com/t5/Community-App-Samples/Collections-Cookbook-50-Visual-Examples-am...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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