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.
23 REPLIES 23
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.

View solution in original post

RandyHayes
Super User III
Super User III

@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.
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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,586)