cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Modifying the Layout of a Gallery using ListBox

Hi,

I am trying to create a gallery from a Collection using ListBox as part of the layout. In the main screen I input 

ClearCollect( IdeasTest, { Participant1: "Change the world", Participant2: "Zero emissions", Participant3: "Idea3"}, 
{ Participant1: "AI for everybody", Participant2: "A robot", Participant3: "An online course"}, 
{ Participant1: "AI algorithm", Participant2: "More holidays", Participant3: "Have more functions on PowerApps"}, { Participant1: "More money", Participant2: "More sleep", Participant3: "More vacations"}, { Participant1: "Bigger Trucks", Participant2: "Idea2", Participant3: "PowerApps"})

 This create a collection that encompasses a group of ideas per participant. Then I insert a Gallery with a ListBox on it. In Items on the Gallery I input IdeasTest, because that is the name of the Collection. However, I get a series of ListBox, and all of the them contain only the information of the first participant and not the others. I got somethin like the attached image.

Does anybody know how to fix this problem? I could input manually the listbox and then assign to each of them the ideas, however, that would not be efficient if the collection is big and changing constantly.

I would appreciate your inputs.

Best!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Modifying the Layout of a Gallery using ListBox

@JBudez 

If you do not know the number of participants in advance this would not be a good way to structure your collection.  Best to abandon solving the for the current collection and work on something entirely new.

 

Here's my suggestion for what the Collection should look like:

ClearCollect(
   IdeasTest,
   { Question: 1, Participant: "Change the world"}, 
   { Question: 1, Participant: "A robot"}, 
   { Question: 1, Participant: "An online course"},
   { Question: 2, Participant: "AI algorithm"}, 
   { Question: 2, Participant: "More holidays"}, 
   { Question: 2, Participant: "Have more functions on PowerApps"},
   { Question: 3, Participant: "More money"}, 
   { Question: 3, Participant: "More sleep"}, 
   { Question: 3, Participant: "More vacations"}
)

 

Put this code in the Items property of the gallery.

RenameColumns(Distinct(IdeasTest,Question), "Result", "currentQuestion")

 

Then use this code in the Items property of the ListBox.

Filter(IdeasTest, Question = currentQuestion)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Modifying the Layout of a Gallery using ListBox

@JBudez 

I suggest you make a small modification to your collection.  Put the square brackets around it to change each record into a Table.

ClearCollect(
   IdeasTest,
   [
   { Participant1: "Change the world", Participant2: "Zero emissions", Participant3: "Idea3"}, 
   { Participant1: "AI for everybody", Participant2: "A robot", Participant3: "An online course"}, 
   { Participant1: "AI algorithm", Participant2: "More holidays", Participant3: "Have more functions on PowerApps"},
   { Participant1: "More money", Participant2: "More sleep", Participant3: "More vacations"},
   { Participant1: "Bigger Trucks", Participant2: "Idea2", Participant3: "PowerApps"}
   ]
)

 

Then to show the response of each participant in a ListBox within the gallery you must use this code in the Items property of the Listbox.

[Value.Participant1, Value.Participant2, Value.Participant3]

 

The result will look like this:

 

result.PNG

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Advocate I
Advocate I

Re: Modifying the Layout of a Gallery using ListBox

Hi mdevaney,

 

Many thanks for your reply, unfortunately the solution you proposed isn't working, it shows me an error does it make a difference if it is a horizontal gallery? Also what happened if I do not know the number of participants as I am importing the collection from a data base?

Best

Jonathan

Highlighted
Super User
Super User

Re: Modifying the Layout of a Gallery using ListBox

@JBudez 

If you do not know the number of participants in advance this would not be a good way to structure your collection.  Best to abandon solving the for the current collection and work on something entirely new.

 

Here's my suggestion for what the Collection should look like:

ClearCollect(
   IdeasTest,
   { Question: 1, Participant: "Change the world"}, 
   { Question: 1, Participant: "A robot"}, 
   { Question: 1, Participant: "An online course"},
   { Question: 2, Participant: "AI algorithm"}, 
   { Question: 2, Participant: "More holidays"}, 
   { Question: 2, Participant: "Have more functions on PowerApps"},
   { Question: 3, Participant: "More money"}, 
   { Question: 3, Participant: "More sleep"}, 
   { Question: 3, Participant: "More vacations"}
)

 

Put this code in the Items property of the gallery.

RenameColumns(Distinct(IdeasTest,Question), "Result", "currentQuestion")

 

Then use this code in the Items property of the ListBox.

Filter(IdeasTest, Question = currentQuestion)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

Highlighted
Advocate I
Advocate I

Re: Modifying the Layout of a Gallery using ListBox

Hi @ mdevaney,

 

Many thanks for your reply. I reckon your solution makes sense, I've just changed the collection and swapped the items "Question" and "Participant" as it makes more sense to me.

 

Best!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,471)