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 / Switch function for st...
Power Apps
Answered

Switch function for status field is not working

(0) ShareShare
ReportReport
Posted on by 138

Hello Team,

I have a gallery formatted grid created, for the status field ..based on the value selected the color gets changed with fill property. When the Status -Draft --it's Blue --working but when I select the status -in progress -the color should be yellow-green .. it is not working out.

On Fill property - used Switch Statement

Switch(true,ThisItem.Status.Value ="Draft",Blue,ThisItem.Status.Value="In progess" ,YellowGreen,ThisItem.Status.Value="Hold" ,Gray,ThisItem.Status.Value ="Closed" ,Red)

Alternative tried--

Switch(ThisItem.Status.Value ,"Draft",Yellow,"In-progess" ,Green,"Hold" ,Gray,"Closed" ,Red)

Salesforce_0-1645711623149.png

 

Similarly, I tried for Text Property --Using emojis

Switch(ThisItem.Status.Value ,"Draft","🔵", "In-Progress","🟢","Closed" ,"🔴") & " " &ThisItem.Status.Value

 

Any help is very much appreciated.

Thanks a lot.

Categories:
I have the same question (0)
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    What type of field is Status?    You might try adding a label in the gallery item to show the value of Status and make sure it's showing what you expect.

     

     

  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    I double checked the yellowgreen color, it works as expected. The issue lies with your In-progress. Sometimes you have it written In Progress, sometimes In-Progress, in data source appears as inprogress. I would, to be safe, copy paste the exact way it is in data source into your formula. The black circles are occurring because your switch lands on no true value, due to the discrepancy of the way in progress is written in your formulas vs the source. ALTERNATIVELY you could take the check for in-progress out of your code entirely and add a , YellowGreen at end to make it the default result if none of the other 3 match.

     

    Regular code I tested and was functional

    Switch(TestSwitch,
     "Draft", Yellow,
     "In-progess", YellowGreen,
     "Hold", Gray,
     "Closed", Red)

     

    alternate way without the in progress check

     

    Switch(TestSwitch,
     "Draft", Yellow,
     "Hold", Gray,
     "Closed", Red,
     YellowGreen)
  • Salesforce Profile Picture
    138 on at

    @JR-BejeweledOne 

    Thanks for the response. Status is a Choice field in SharePoint list, in gallery form -the label is used for the Status --Draft (value)--I'm using a Circle icon to color with fill property.Any suggestions very much appreciated

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Your answer will be somewhere in my post above, your issue stems from there being no exact match for the value tied to YellowGreen, black is default color.

  • TheRobRush Profile Picture
    11,128 Moderator on at

    In one of these it is looking at variable of "In-progress" and in the other "inprogress"coloexam.PNGcoloexam2.PNG

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Have you checked @TheRobRush 's answers?   He is on the right track.    Add a label to your gallery and set it to ThisItem.Status.Value, then check the value on the In Progress items.  Use that value exactly in your switch statement.

  • Salesforce Profile Picture
    138 on at

    @TheRobRush 

    Thanks for the response.it's given as Inprogress. I tried using the below functional. The Color is not getting changed.Any suggestions are very much appreciated.

    Switch(ThisItem.Status.Value,
     "Draft", Yellow,
     "Inprogess",Blue,
     "Hold", Gray,
     "Closed", Red,
     Orange
    )

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Is it giving you any error marks on the code written like that? I don't think you should need the .value part.

     

    To demonstrate I moved my switch from checking a test variable i was using just to show you syntax to check an actual splist gallery source.

     

    Works written like this just fine

     

    Switch(ThisItem.COACHINGTYPE,
     "Draft", Yellow,
     "Hold", Gray,
     "Opportunity", Red,
     "Positive", YellowGreen)

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I figured out your issue.   You need to delete your switch statement and then retype it.  Do NOT copy and paste.   It looks perfect but something isn't right with it.

     

    I copied and pasted your formula to my test and got the same issue you are having.   It does not work with blue, however when I deleted the formula and typed it manually, it works.

     

    @TheRobRush,

     

     

  • Salesforce Profile Picture
    138 on at

    @JR-BejeweledOne --As suggested-i have manually retype the formula..in between it power apps page was troubling for Wait or Exit Page, After a few minutes, I tried it out it worked.

    @TheRobRush .

    Thank you very much both of you. I tried using different colors in the formula for label and Circle for the outputs

     

    Salesforce_0-1645732551914.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard