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 / CDS optionset value in...
Power Apps
Answered

CDS optionset value in Switch command

(0) ShareShare
ReportReport
Posted on by 174

Dear community

I have a gallery and I want to change the template fill property based on the value of an option set.
ThisItem.'Agreement Status' -> this is an Option Set field in CDS. With 5 options:
Not Sent (Value: 0) 
Out for Signature (Value: 1)
Signed (Value: 2)
Declined (Value: 3)
Canceled (Value: 4)

Switch(ThisItem.'Agreement Status',0,Red,Green) nor Switch(ThisItem.'Agreement Status',"Not Sent",Red,Green) isn't working.
What am I doing wrong?

Thanks!
Bart


 

Categories:
I have the same question (0)
  • timl Profile Picture
    36,785 Super User 2026 Season 1 on at

    Hi Bart,

    From the test that I did, referencing option set field returns the option set text, rather than the ID. This is probably one cause of the problem.

    If your requirement is to set the fill property to read if the status is 'Not Sent', and to set it to green for other statuses, you can accomplish this more easily with the If function. The syntax I would try is this:

    If(ThisItem.'Agreement Status' = "Not Sent",
     Red,
     Green
    )

     

  • BClouded Profile Picture
    174 on at

    Hi timl
    Thanks for your response, unfortunately that gives an error "Incompatible Type".

    BClouded_0-1598957773014.png

    I did to so many times with choice fields in SP datasource but in CDS this seems so much more complicated... 😕

  • Verified answer
    timl Profile Picture
    36,785 Super User 2026 Season 1 on at

    Hi @BClouded 

    Sorry about that - could you try the following?

     

    If(ThisItem.'Agreement Status' = [@Agreement Status].NotSent,
     Red,
     Green
    )

     You should be able to access the Agreement Status enumeration through [@Agreement Status]. If not,  you could try [@'Agreement Status']. Hopefully, this will work.

  • BClouded Profile Picture
    174 on at

    @timl 

    Thanks mate! 🙂

  • timl Profile Picture
    36,785 Super User 2026 Season 1 on at

    You're welcome - glad that helps!

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 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard