cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Data_Enthusiast
Post Patron
Post Patron

Change question in Gallery

Hi Power Apps Community,

 

I am currently creating a survey in Power Apps. 

 

Issue: I am using a Gallery to list all the questions and Radio Input. However, I have one question which requires Text Input. When using a Gallery, the Radio Input is replicated to all the questions. Is there any way that I could replace the Radio Input for a Text Box in the last question? - as seen in the image below.

 

Data_Enthusiast_0-1602017059276.png

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Data_Enthusiast 

How are you designating your "question types" in your items list for that Gallery?

You will need to key off of that.  So, for example, if your Items record contains a "dataType" column that designates what kind of question control it should have (Radio, Text, etc).  Then you can add the TextInput to the Gallery and set its Visible property to ThisItem.dataType = "Text" and the Visible property on your Radio control to ThisItem.dataType="Radio"

That should give you what you want.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
RandyHayes
Super User
Super User

@Data_Enthusiast 

How are you designating your "question types" in your items list for that Gallery?

You will need to key off of that.  So, for example, if your Items record contains a "dataType" column that designates what kind of question control it should have (Radio, Text, etc).  Then you can add the TextInput to the Gallery and set its Visible property to ThisItem.dataType = "Text" and the Visible property on your Radio control to ThisItem.dataType="Radio"

That should give you what you want.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes ,

Brilliant! Thank you for the quick response. I tested this out and it worked! 😀

@Data_Enthusiast 

Excellent!  

As a side-note, I am currently editing a video on the process of building long survey type questionnaires like you seem to have.  It's an end-to-end solution video.  The video Channel is still in its infancy stage, but I'm aggressively working on a long list of video topics.  Go ahead and subscribe there so when it is done, you can check it out - I believe you will be able to apply a tremendous amount of information in it to you App.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

I will definitely give it a look. Thanks!

I think I'm trying to do what you're doing @RandyHayes and I'm stuck.  I have a sharepoint list that contains my questions and some columns used for filtering.  This way the admin can add/edit/remove questions without editing the PowerApp.

 

I created the PoweApp with a gallery that pulls the questions, and I added the input fields for their response in to the gallery template.  It looks great and uses filters to change the questions displayed.

 

Now I'm stuck trying to figure how to capture the values from the input fields.  I just realized that every field is ThisItem.TextField and I don't know how to get each row's answer.  I was hoping your video was posted but didn't see it.

@PeteFromDenver 

I'm working on it still.  It's a long one, so it is taking some time to put together - especially when I only get some spare time to do it.

 

In general, what I do is to capture any value in a label in the Gallery (let's say labelAnswer).  The concept of the formula on the text property of the label is this:

Switch(ThisItem.dataType,
    "Text", textInputBox.Text,
    "Radio", RadioControl.Selected.Value,
    "Slider", Text(SliderControl.Value),
    "Date", Text(DatePickerControl.SelectedDate, ShortDate)
)

 

Now from that label, you can get all the values of the answers directly from the labelAnswer.Text value.

 

You're making me itch to finish the video...I will put some work into it this weekend.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks @RandyHayes  for your reply. I managed to get the gallery display the right type of input field. But the set step that I'm not figuring out is How do I collect the values they are answering when they click the submit button it will create a single record in a SharePoint list?  I use one SP list to supply the questions and want a another SP list to store the results by people.  Is this even possible with a gallery?

 

For a generic example if they answer Question A with option 1 and answer Question B with option 2. 

The screen has the components

gallerySurvey

- txtAnswer

- lblQuestion

btnSubmit

 

This is an example of the real inspection form I'm creating.

gallerysample.png

Just figured out part of it.  I had to do something like

 

Clear(Collection_Test);

ForAll(galleryEhsEquipment_1.AllItems,Collect(Collection_Test,{Question:Question_4.Text, Answer:ResponseAnswers2_3.Selected.Value})) 

 

Now just need to convert a gallery of rows containing Question ID and Answers in to a record with columns for each question and it's corresponding answer.

@PeteFromDenver 

Since you are doing this in a running Gallery, you can simply put a Label in your gallery (hidden) and set the text property to the value of the current row based on its control.  

ex:

Switch(ThisItem.questionType,
    "Text", yourTextInputControl.Text,
    "Radio", yourRadioControl.Selected.Value,
    ...etc...
)

 

Then at the end of it all, you can reference Gallery.AllItems and then get the value in the label control as the answer to the question.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,657)