Announcements
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 )
@MIA27 -
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!
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.
It is not lower case, and does not have space at the start.
Also please note to test I put the below and it works
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!
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
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) ) )
Not worked, so frustrating, such a simple formula, not working.
When I apply with if for testing purpose, the left function works
Finally it worked
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 401 Most Valuable Professional
11manish 201 Super User 2026 Season 2
MS.Ragavendar 128 Super User 2026 Season 2