Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Answered

Images not displaying in image control

(0) ShareShare
ReportReport
Posted on by 5,836
I have a gallery with an image control.   I am displaying any one of 4 images depending on specific values in the gallery items.  At the very least it should be displaying the dot.  The properties ship, called and hit are all true/false.
 
Switch(ThisItem.Ship,

    true, If(ThisItem.Called && ThisItem.Hit, "Fire",
             ThisItem.Called && !ThisItem.Hit, "Radar",
             "BlueAnchor",
             
    false, "Dot")
    )
The images are uploaded to Power Apps. There are no errors in the switch statement, but no images are being displayed either.  I have tried using the Image name with and without the .png at the end.  This same switch statement works fine if I use an icon rather than an image.
 
 
        
 
 
 
 
 
 
 
 
  • WarrenBelz Profile Picture
    WarrenBelz 144,858 on at
    Images not displaying in image control
    Just because it is less complex in your case - I generally only bother with Switch when there are more than two possible results (which saves specifying the value multiple times) otherwise it is simply If/then/else.
  • JR-BejeweledOne Profile Picture
    JR-BejeweledOne 5,836 on at
    Images not displaying in image control
    @@WarrenBelz do you mind if I ask why?  I would like to understand why you would prefer the If statement.
  • WarrenBelz Profile Picture
    WarrenBelz 144,858 on at
    Images not displaying in image control
    To be honest, I would get rid of the Switch
    If(
       ThisItem.Ship,
       If(
          ThisItem.Called && ThisItem.Hit, 
          Fire,
          ThisItem.Called && !ThisItem.Hit, 
          Radar,
          BlueAnchor
       ),        
       Dot
    )
     
  • Verified answer
    JR-BejeweledOne Profile Picture
    JR-BejeweledOne 5,836 on at
    Images not displaying in image control
    @
    Switch(ThisItem.Ship,
    
        true, If(ThisItem.Called && ThisItem.Hit, Fire,
                 ThisItem.Called && !ThisItem.Hit, Radar,
                 Anchor),
                 
        false, Dot
        )
        
    @WarrenBelz  I was initially getting an error that it expected an image value.  The quotes removed that error, but it appears that the other error was the whole problem.  Here is the modified working formula.  Note that I removed the 'true' value after ThisItem.Ship.   ThisItem.Ship is already a true/false value and adding true gave another error.
     
     
     
     
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 144,858 on at
    Images not displaying in image control
    Firstly, you do not need quotes "" around the image names
    Switch(
       ThisItem.Ship,
       true, 
       If(
          ThisItem.Called && ThisItem.Hit, 
          Fire,
          ThisItem.Called && !ThisItem.Hit, 
          Radar,
          BlueAnchor
       ),        
       false, 
       Dot
    )
    There was also a bracket in the wrong place
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

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.

Helpful resources

Quick Links

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard