web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Show images randomly i...
Power Apps
Answered

Show images randomly in te screen backgound

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have been trying to display 1 of the 6 images randomly whenever someone opens the app. I tried to make a collection of all the images and use shuffle for randomization. Although it does not give any error but it doesn't show the image as well although my function is producing image output by using ".url" property. Looking for possible reasons or any alternate ideas.

 

Capture.PNG
Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @Anonymous ,
    One other possibility is to import the images into the media (View > Media > Images > Browse) and they will be named as per the original file. At App OnStart, you could have

    Set(
     vRN,
     Round(
     Rand() * 10,
     0
     )
    )

    which generates a random number between 0 and 9 - you can duplicate four of the images if you have no more.
    Put a Image control at the back of the screen with the Image property

    Switch(
     vRN,
     0,
     ImageName1,
     1,
     ImageName2,
     2,
     ImageName3,
     3,
     ImageName4,
     4,
     ImageName5,
     5,
     ImageName6,
     6,
     ImageName7,
     7,
     ImageName8,
     8,
     ImageName9,
     9,
     ImageName10
    )

    and you will have one of 10 random images displayed.

     

    Please click Accept as solution 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 Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous 

    I didn't even know there was a function called Shuffle(), but now I do 🙂 

     

    I got this to work for my setup by re-collecting the collection using the Shuffle function. What I did was (I have a SP Library with images):

     

    Button1.OnSelect = ClearCollect(colImages, mySPList) // this gets my original collection of images

     

    Button2.OnSelect = ClearCollect(colImages, Shuffle(colImages)) // this shuffles and re-creates the above collection.

     

    You could just work the above code / process into your OnVisible / App OnStart?

     

    EDIT: Whoops sorry @WarrenBelz , stepped away from the laptop when halfway through responding then came back to finish off and you've already responded 🙂 

     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    No problems @Anonymous - I did the same to someone else this morning. (and had not heard of Shuffle either)

    My main response focus was on the URL not working and suggesting the images be imported into the app Media. I do this on our training app where each subject has a different background. The Random was an extra.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @WarrenBelz  and @Anonymous for your replies. I tried Warren's approach for now and it worked and doing so i figured out the problem with my approach as well. So since i was trying to make my collection earlier on app start therefore it wasn't showing me the desired results on power studio. Even when i used Warren's method that too wasn't showing results on app start property. But when i use a button to make the collection an then do it using either my or Warren's method it starts working on app studio as well. so i guess now i will have to implement it on app start an then trust the app to work just fine once i publish the app. That's my observation for now.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard