I am trying to set image in the gallery based on condition, But not working, No error no image on display
please guide what is the error making:
Switch(
Left(ThisItem.Model,1),
"B",
Bulldozer,
"E",
Excavator
)
Finally it worked
Not worked, so frustrating, such a simple formula, not working.
When I apply with if for testing purpose, the left function works
Hi @MIA27,
I forgot to prefix ModelFirstChar with ThisItem. My apologies.
Switch(
//Changed here
ThisItem.ModelFirstChar,
"B",
Bulldozer,
"E",
Excavator
)
Should the change above still result in no images - you may want to add this AddColumns when collecting the data instead:
ClearCollect(
AddColumns(
DataSource,
"ModelFirstChar",
Left(Model, 1)
)
)
I hope this helps!
I applied the code as below, but getting formula error as shown in the below image
//Gallery items property
AddColumns(
colAllList, //replace with your datasource or Filter statement
"ModelFirstChar",
Left(Model, 1)
)
//Image property of the Image control
Switch(
ModelFirstChar,
"B",
Bulldozer,
"E",
Excavator
)
Please guide the correction
Hi @MIA27,
I suspect that this may be caused due to explicit column selection. A workaround would be defining the required columns via ShowColumns() in your gallery items property.
In your case you could add an additional column containing the Left value:
//Gallery items property
AddColumns(
Datasource, //replace with your datasource or Filter statement
"ModelFirstChar",
Left(Model, 1)
)
//Image property of the Image control
Switch(
ModelFirstChar,
"B",
Bulldozer,
"E",
Excavator
)
I hope this helps!
Also please note to test I put the below and it works
It is not lower case, and does not have space at the start.
Data source - Table in Teams
Data Type of Model is Text
Yes, the file name is correct. Because I test in another gallery, in another situation where Left was not been used.
Hi @MIA27,
The function looks ok - using this approach however is case sensitive. Could it be possible that the Model starts with a lower case instead of an upper case?
Switch(
//Lower avoids case sensitivity by defaulting it to lower case
Left(Lower(ThisItem.Model),1),
"b",
Bulldozer,
"e",
Excavator
)
(Make sure Model never starts with a space, otherwise you may need to use the Trim() function as well)
If this solves your question, would you be so kind as to accept it as a solution.
Thanks!
@MIA27 -
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional