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 / Default color on condi...
Power Apps
Unanswered

Default color on conditional background

(0) ShareShare
ReportReport
Posted on by 2

Hi,

I have a CanvasApp where I change some items' fill color based on a condition, using the Switch() function. The data it checks, comes from a Sharepoint list, therefore the loading time is a bit long. 1-2 seconds maybe but it is visible and while the app is loading and the query is in process the fill color just defaults to black which is ugly.

 

Is there any way to change this default color, or to show -something- until the query is done and the condition has returned with a value?

Categories:
  • SpongYe Profile Picture
    5,909 Super User 2026 Season 2 on at

    Hi @fbf-ehu 

     

    I would suggest to use the Set() function to create a global variable that stores the color you want, and then use that variable in the Fill property to sow the color.

     

    For example, you can add this code to the OnStart property of your app: 

    Set (gblColor, Blue)

    or whatever color you want, and then set the color to your preferred color in the Switch if the condition has returned with a value.

     

    Your code would like: 

    Set(gblColor, Color.Blue);
    Switch(
     Slider1.Value, 
     20, 
     Set(gblColor, Color.Yellow), 
     25, 
     Set(gblColor, Color.Green), 
     30, 
     Set(gblColor, Color.Purple);
    )

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Hi @fbf-ehu in your switch that is setting the colours you can also provide a default value the syntax for the switch statement is: 

     

    Switch(SwitchValue, Match1, Result1, Match2, Result2, DefaultResult)

     

     

    Alternatively you could do a check to see if the field you are pulling is blank or empty and structure like so: 

     

    If(
     IsBlank(YourField)||IsEmpty(YourField),
     Color.YourColorChoice,
     Switch(SwitchValue, Match1, Result1, Match2, Result2, DefaultResult)
    )

     

    I think using @SpongYe  global variable will also give you the solution to this! That may be a better way! 

     

     

    Please click Accept as solution if my post helped you solve your issue. ✔️ This will help others find the solution to this problem. It also closes the item. Remember, you can accept more than one post as a solution.

    If the content was useful in other ways, please consider giving it Thumbs Up. 👍

    Thanks
    Andrew

  • fbf-ehu Profile Picture
    2 on at

    Thank you for the suggestions @SpongYe , @AndrewR1 !

    I tried both, however, neither of them solved my problem, since the field I'm checking is never empty, nor blank, so one of the conditions will always be met. Neither the empty/blank check, nor the switch's default case will be run. 

    The "default" color is only visible when the app itself is loaded for the first time and the queries of the Sharepoint fields are still running.

     

    I have also tried creating a loading screen, but I coud not figure out to way to decide when it can be hidden. Maybe I could check wether all the items' Fill property is !Blank but I will have to experience with this a little more.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard