cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lknudson1
Advocate II
Advocate II

conditional fill coloring formatting in gallery for iOS not working

I have a gallery that has a date field from a SQL data source that I want to have a conditional fill color applied based on the date being equal to a selected date on the main screen.  This works fine in development mode and run mode in Windows.  When I open the app in an iPad or iPhone, the fill for all date fields is black.  Here is the logic to pick color:

 

If(IsBlank(ThisItem.Stock_Date), White, // This checks to give default color if no date value
// if there is a date value, test if the gallery field date is equal to selected date
      If(DateValue(Text(ThisItem.Stock_Date,"[$-en-US]yyyy//mm//dd"))

       =

        DateValue(Text(DatePicker1.SelectedDate,"[$-en-US]yyyy//mm//dd"))  ,
                     Yellow, // if dates are equal, Fill will be Yellow
                      White) // if dates are not equal, Fill will be White
   )

Example from Windows run shows below as I want it with yellow fill for date when 08/05 is selected from date picker control on main screen.

But on iPad, fill will be black for all date fields in gallery.

Any help?

lknudson1_0-1628631679395.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
lknudson1
Advocate II
Advocate II

Well, I got it to work with what's below.  Not sure why iOS was so fussy.

 

If(!IsBlank(ThisItem.Stock_Date),
If(
DateValue(ThisItem.Stock_Date)
=
DatePicker1.SelectedDate,
Yellow, White),
White)

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@lknudson1 

Please consider changing your Formula to the following:

If(IsBlank(ThisItem.Stock_Date), White, 
    ThisItem.Stock_Date = DatePicker1.SelectedDate, Yellow,
    White
)

See if that works better for you.

 

I hope this is helpful for you.

_____________________________________________________________________________________
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!
lknudson1
Advocate II
Advocate II

Well, I got it to work with what's below.  Not sure why iOS was so fussy.

 

If(!IsBlank(ThisItem.Stock_Date),
If(
DateValue(ThisItem.Stock_Date)
=
DatePicker1.SelectedDate,
Yellow, White),
White)

RandyHayes
Super User
Super User

@lknudson1 

So you're stating that the Stock_Date column in your list is a text column.  If so, then yes, this is key to remember that the PowerApps designer is very forgiving of type conversions (numbers to text, text to numbers, dates to text, etc).  However, the Play Apps on the mobile devices are NOT forgiving.  If they have any type conversion problems, they will just error out in the formula and in your case you would get a blank result for your color...which is black.

This is one of the main causes of "my app works fine in design mode, but when I play it on the app, it does not work - why?"

_____________________________________________________________________________________
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!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,048)