Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

(1) ShareShare
ReportReport
Posted on by 112

Hi Community,

 

I tried and searched for an answer but still couldn't figure it out so hoping someone can help me.

 

I have a dataverse table with a bunch of questions, it's quite simple, i have Category, QuestionID, Question and Answer where 3 options in a choice column "Yes", "Maybe", "No". 

 

When I created a gallery to display the questions by category, with a dropdown box insert in the gallery for each question, I manage to get the defautselelecteditems to show the patched/existing answer.  I used a collection in the Answer's dropdown box OnChange property so that if/when user click to select/change answers from the drop down, the final result will be patch via ForAll of the collection.  Since I have to break down the display of questions by category, I use TabList to control which category to switch to showing which batch of questions, the gallery underneath the Tablist will then filter the related category accordingly, now, when user selects answers in the previous gallery, once they click to switch to anther category, meaning the gallery will display, say instead of question 1-6, now it will display 7-13, and if user decides to go back to check what they selected previous in 1-6, all the selections in the dropdown will be gone, meaning the answerdropdown box ddanswer.Selected.Value doesn't hold the value.  If there was existing old value, it will show as it was the defaultselecteditem.  

 

How do I keep the selected value of all the answers when user makes changes?  I suppose I need to revise the defaulselecteditem part but whatever I tried, it just doesn't work.

 

My defaultSelectedItems for the answer dropdown box is 

Filter(Choices(Questionnaires.Answer), Value = ThisItem.Answer)
 
This shows the existing patched value.  Any help is greatly appreciated!
 
S
  • BoboLee Profile Picture
    33 on at
    Re: Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

    I guess you put the table e.g. Questions in the data source of the table with filter of the category. 

    In the OnChange of dropdown or combo box of the the answner:

    If(
        !IsBlank(Self.Selected),
        Patch(
            Questions,
            ThisItem,
            {
                Answer:Self.Selected.Value
            }
        )
    )
  • sc0rpiongirl Profile Picture
    112 on at
    Re: Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

    Actually upon thinking it over, I suppose the only way around this is to patch the answers to each category when user click the TabList to switch cateogries, that way whatever user selected for that category, before switching, after being patched, will become the most recent "existing record" therefore will display as defaultselecteditems...

     

    Here is my Answer dropdown box OnChange property:

    OnChange = 

    If(
        !IsBlank(
            LookUp(
                colAnswers,
                QuestionID = ThisItem.QuestionID
            )
        ),
        UpdateIf(
            colAnswers,
            QuestionID = ThisItem.QuestionID,
            {Answer: ddAnswer.Selected.Value}
        ),
        Collect(
            colAnswers,
            {
                QuestionID: ThisItem.QuestionID,
                Answer: ddAnswer.Selected.Value
            }
        )
    );
     
  • BoboLee Profile Picture
    33 on at
    Re: Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

    What's the code in OnChange? BTW if user selects the same category the value will be clear. 

  • sc0rpiongirl Profile Picture
    112 on at
    Re: Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

    Thanks for the quick reply. ThisItem.Answer is currently / already the default of the data field. I tried all type of combination in filter / lookup etc to try to hold the value in ddAnswer but to no avail. (Eg tried to lookup the colAnswers  (the collection to hold user’s answer etc) but as soon as user switch category which means the gallery is filtered to show the next batch of questions, all the previous answers to the questions in dropdown is gone…

  • BoboLee Profile Picture
    33 on at
    Re: Issue Displaying DropDown Box Selected Value in Power Apps with Dataverse table source

    Dropdown uses "default" while combobox uses "DefaultSelectedItems" - you can just put ThisItem.Answer in the default and Choices(Questionnaires.Answer) for the items

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,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard