Hi all
I would like to change the container fill color based on the label text that contains an email address using the "in" function also like to use a switch function how could I use both for the fill properties for container?
code currently
Switch(
true,
DateDiff(
Today(),
DatePicker1
) < 6,
Color.DarkRed,
DateDiff(
Today(),
DatePicker1
) > 6,
Color.DarkGreen,
DateDiff(
Today(),
DatePicker1
) = 6,
Color.DarkGreen
)
Thank you
Hi @moerah,
Thank you for the additional info! The code below will first check whether that particular line contains a valid email format, if not then we go through the day colors. If I understand it correctly, a filled in email has priority over the date difference check.
If(
//Check whether the Text Input contains a valid email
IsMatch(
//Change to the correct control
TextInput1.Text,
"^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$"
),
Color.Green,
//If not, go through the DateDiff logic
DateDiff(Today(), DatePicker1.SelectedDate) < 5,
Color.Red,
DateDiff(Today(), DatePicker1.SelectedDate) > 10,
Color.Green,
//Else (between 5 and 10 days)
Color.Orange
)
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473