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
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 )
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.
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 -
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Tom Macfarlan as our Community Spotlight for October…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 885 Most Valuable Professional
developerAJ 571
Michael E. Gernaey 352 Super User 2025 Season 2