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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Powe flow - set Choice...
Power Apps
Unanswered

Powe flow - set Choice value by text

(0) ShareShare
ReportReport
Posted on by 127

I'm working on a flow to read a user list from Excel and import into power app dataverse table. The Excel contains text where I need to map to the corresponding choice for Choice data type fields.  For example, Excel gender will be Male, Female. In dataverse, the field would be mapped to the matching choice Male, Female. The flow edit screen shows a dropdown asking to choose which choice. I need a dynamic expression that will default the choice to Male if the Excel text is Male.

 

Currently I would have to set a static Variable Object with hardcoded choice IDs but this is cumbersome especially when it comes to Choices list with a lot of options.

 

Gender
{
"Male": "922610000",
"Female": "922610001",
"Other": "922610002"
}

 

then use the expression

 

if(not(empty(outputs('Get_response_details')?['body/r59896276b4f44249a311f6d93d7703a7'])), variables('Gender)[outputs('Get_response_details')?['body/r59896276b4f44249a311f6d93d7703a7']], null)

 

I have the same question (0)
  • AhmedSalih Profile Picture
    6,678 Moderator on at

    Hello, @tedqn77, I have just made a video yesterday and it include this case: add the Option set label value inside an array: Here is the video and it will start from the minute 29 where I showed how to do this:https://youtu.be/ntFDddYbcNE?t=1740

     

     

    If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.com


     

     

  • AhmedSalih Profile Picture
    6,678 Moderator on at

    @tedqn77, so basiccly you will have to use a variable (type is string). This variable need to be Set using the Item or Items function. 

    Item()?['ChoiceColumnLogicalName@odata.community.display.v1.formattedvalue']

    Then you will use this variable inside your array.

     

     

    If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.com


     

     

  • tedqn77 Profile Picture
    127 on at

    Thank you Ahmed. What I need is the reverse of that. In the Excel I get the display label (i.e Male). I need the id to pass into the dataverse column value. So given the label "Male", I need to look up an option in Choices matching "Male" and get "922610000" to pass to the dataverse column value.

     

     

  • AhmedSalih Profile Picture
    6,678 Moderator on at

    @tedqn77, Are you using Add row or Modify row?

     

     

    If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.com


     

     

     

  • tedqn77 Profile Picture
    127 on at

    It does both. If the ID matches an existing ID then update otherwise insert a new record.

  • AhmedSalih Profile Picture
    6,678 Moderator on at

     @tedqn77 , 

    The easiest way is to generate this variable:{
    "Male": "922610000",
    "Female": "922610001",
    "Other": "922610002"
    }

     

    To do this:

    Use the Folowing Steps:

    1. Initialize Array Variable: call it varDataverseChoiceTable
    2. List Rows Action using the Dataverse table
    3. Select Function and use the value of the Previous List Rows Action in Step 2

        

      ChoiceColumnValue >> item()?['ChoiceColumnLogicalName']

      ChoiceColumnLabel >> Item()?['ChoiceColumnLogicalName@odata.community.display.v1.formattedvalue']

       

      4. Compose and use this expression union(body('Select'),body('Select')) << To get Distinct values ONLY

      the output of this compose will something like this:

      [
        {
          "ChoiceColumnValue": 0,
          "ChoiceColumnLabel": "Active"
        },
        {
          "ChoiceColumnValue": 1,
          "ChoiceColumnLabel": "Inactive"
        }
      ]
       
       

      If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


      I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


      Visit my Blog: www.powerplatformplace.com


       

       

  • AhmedSalih Profile Picture
    6,678 Moderator on at

    @tedqn77, one last step is to Apply to each using the compose value, and Append to Array variable that you need to initialize in the begining of the flow:

    AhmedSalih_0-1673301616166.png

     

    the item to the left: item()?['ChoiceColumnLabel']

    the item to the right: item()?['ChoiceColumnValue']

     

    The final result:

    [
      {
        "Active": 0
      },
      {
        "Inactive": 1
      }
    ]

     

     

    If my reply helped you, please give a 👍 , & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard