Skip to main content

Notifications

Community site session details

Community site session details

Session Id : aZV8RTKves1HxlQLxJ/ghJ
Copilot Studio - General
Answered

How can I reference choice variables using Power fx?

Like (0) ShareShare
ReportReport
Posted on 16 Feb 2023 15:46:34 by 10

I have a bot topic that at some point, needs to set a variable based on a choice the user has made in a previous part of the flow.

 

The problem is, the Choice field is not recognised as a same comparable type as Text, so my formula isn't working. I've had this issue before using Power fx with Power Apps, and I know that there is a way to reference the choice itself, rather than a text value, but there appears to be no "Choices" function built into the PVA side of things. Does anyone know how I reference the Choice correctly?

 

Here's a sample of the code not working below:

 

 

If(Topic.selectedColor = "Blue", true, false)

 

 

 

The error I'm receiving is:

Incompatible types for comparison. These types can't be compared: OptionSetValue(cr559_bot.topic.colorpickerflow.main.question_Ckz917), Text

 

Thanks

  • benshikari Profile Picture
    10 on 16 Feb 2023 at 21:09:47
    Re: How can I reference choice variables using Power fx?

    Fantastic, thanks @HenryJammes - I'm not sure why I didn't even think about casting as Text but I'm glad it works and you pointed it out! Thanks again.

  • Verified answer
    HenryJammes Profile Picture
    on 16 Feb 2023 at 19:11:19
    Re: How can I reference choice variables using Power fx?

    Can you try by changing the format of your variable to text?

     

    If(Text(Topic.selectedColor) = "Blue", true, false)

     

    Also, not sure if it helps, but I had explored dynamic options in that post, and I manipulated these in Power Fx too:

    Solved: Re: How can I use Dynamic Multi-choices in the PVA... - Power Platform Community (microsoft.com) 

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,011 Most Valuable Professional

Leaderboard
Loading started
Loading complete