cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Gallery Template fill based on value in 2nd gallery

I need to set the template fill of a gallery if the date exists in a 2nd gallery.

 

Gallery1 - Dates

   Title - Number

   Subtitle - Text

   Label7 - Number

 

Gallery2 - (Vertical Blank Flexible Height) Items

   LabelDate - Text

   LabelHoliday - Text

 

If Gallery1 Subtitle (text date) is in Gallery2 LabelDate (any item), then I need the template fill to be a color other than white.

 

In trying to do this, the only comparison option I have in Gallery1 is ThisItem.Value.  I can't select one of the controls inside the gallery item.   ThisItem.Value evaluates to a number but it won't allow me to use the = operator to compare to the number field inside gallery2.

 

GalleryCompare3.png

 

GalleryCompare1.pngGalleryCompare2.png

 

Would appreciate suggestions and recommendations.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
24 REPLIES 24
JR-BejeweledOne
Super User
Super User

Got it!

 

Even though Gallery2.Date was showing as a Date, it wasn't comparing that way.  This works.

 

GalleryCompare11.png



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

So from your last formula I had assumed that Date was the name of the label in your Gallery.  Looking back, I see that perhaps it is called LabelDate

Subtitle2 is a label...it has a Text value.  It doesn't matter what is in the text, it is Text!  If you have "Hi" in the label, it is Text, if you have 1 in the label, it is text, if you have 5/12/2021 in the label...it is Text.

So what the label has plays no part in conversion. 

What seemed to be at play was that Date is a column in the Items source of your Gallery (and obviously in a text format).  The point though is that your label has the converted date to text - I was just referencing the wrong one.

 

Although your formula might work, you're actually producing more overhead to the app than necessary.  You've already gone through the conversion of the Date to Text in the Gallery 2 label.  So, with your formula, you are just doing it again.

 

So, your formula should really be:

   If(LookUp(GalleryHolidays.AllItems, LabelDate.Text = Subtitle2.Text, true), Style.DayBG, White)

 

With the above, there is no additional duplicated overhead of date conversion.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Sorry, neglected to mention that I removed the DateValue conversion in Gallery2 and just left it at ThisItem.Date.   I had added it early on when I was trying different things to compare.   I realized I didn't need it once I had to convert it in the formula.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

Yes, but the fact that you have a label that has a Date value (ThisItem.Date) as its Text property means that PowerApps is already going to convert it to the proper formatted date according to your regional information....so there was no other conversion needed.  Again, just a Text to Text compare.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
selenev
Regular Visitor

This is exactly what I needed it. Thanks!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,285)