
Hi,
I am trying to fill the background colour of a gallery based on several different dates, or based on text if no date is required.
My date label has the following code:
If(IsBlank(Text(ThisItem.ExpiryDate)), "Expiry - N/A", "Expiry - " & " " &
Text(ThisItem.ExpiryDate, DateTimeFormat.LongDate))I have got this working fine for the dates, but when the text is "Expiry - N/A", I can't get it to change to green which is the colour I would like for this specific text. Here is the code I have for the Gallery Fill property:
If(
//Check if it is later than 2 months from today
ThisItem.ExpiryDate > DateAdd(
Today(),
2,
Months
),
RGBA(//Green
14,
209,
69,
0.2
),
If(
//Check if it is today or older
ThisItem.ExpiryDate <= Today(),
RGBA(//Red
255,
0,
0,
0.2
),
//Anything else
RGBA(// Orange
255,
191,
0,
0.2
)
)
)I have tried adding another If statement but could not get it to work, I also tried a Switch statement but that did not work either. I am guessing it is because the text is not a date. Here is a screenshot of what I have so far, the red should be green as it says "Expiry - N/A".
Can any one help with this please
Thanks in advance
try this, think it's right but typed in a notepad so may be missing a piece of punctuation, nbut oitherwise should be correct
Switch(
IsBlank(Text(ThisItem.ExpiryDate)),
true, RGBA(//Green
14,
209,
69,
0.2
),
If(
//Check if it is later than 2 months from today
ThisItem.ExpiryDate > DateAdd(
Today(),
2,
Months
),
RGBA(//Green
14,
209,
69,
0.2
),
If(
//Check if it is today or older
ThisItem.ExpiryDate <= Today(),
RGBA(//Red
255,
0,
0,
0.2
),
//Anything else
RGBA(// Orange
255,
191,
0,
0.2
)
)
)
)