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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Expansion/accordion wi...
Power Apps
Answered

Expansion/accordion with a gallery

(0) ShareShare
ReportReport
Posted on by 110

I have a gallery that diaplys 6 Districts.I need to have an onselect for the label or a directional arrow that expands to show the retail locations of the district selected. My reserach has yielded nothing in terms of expandinf or accordion capabilities. I am consdiering auto fit galleries. I have also been playing around with visibility but to no avail. I used a checkbox and added to the oncheck/offcheck sections:

 

Label1.visible=True

 

Is that correct? 

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @Hockeyman9474,

     

    Based on my understanding, I think here you could add another gallery (Gallery 2), then change its items property with the code below:

    Filter(RetailLocationsTable, Districts=Gallery1.selected.Dustricts)

    For selection, change the Onselect property of the Label or the directional arrow to navigate to the Gallery2 screen, then under gallery 2 screen, add a button to navigate back.

    For Visible property, we can't assign values to the visible property of controls in formula, but we could write formula with the visible property.

    For example, you would like to configure the visible property of Label1 on condition of some action (For example, pressing a button), then with the visible property of the label1 control, we could use:

    If (Button.pressed, true, false)

     

    Regards,

    Michael

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Hockeyman9474

     

    Have you seen this blog?

    https://powerapps.microsoft.com/en-us/blog/ux-patterns-expander-control-with-expand-collapse-animation/

     

    I have successfully managed to achieve an expandable gallery with this. Also, as suggested by @v-micsh-msft instead of using a label inside the gallery, I am using a second gallery filtered based on the parrent gallery.

     

    Hope this helps 🙂 if you need more details, let me know

  • Hockeyman9474 Profile Picture
    110 on at

    Yes but it's confusing and I don't understand it. The poster doesn't elaborate very much. For example I don't have the expander tool, and the poster isn't specific so it's hard to follow. Can't I add a flexible height gallery and make it visible by clicking an arrow? Why is this concept so hard to apply when it's such a common occurence. Powerapps is not very intuitive when it comes to this. Big limitation in my oppinion.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Hockeyman9474

    Let me try to explain how I have achieved this.

     

    First use a 'Blank flexible height' gallery.

    Add a label to display the District name and under that add another 'Blank flexible height' gallery which will display the locaitons in the district selected.

    Now insert 2 icons: 'Up' (collpase) and 'Down' (expand) so that they are one on top of the other one and set the following properties on them

    1. for the 'Up' (collapse) button:

    - Visible: expandCollapse && ThisItem.IsSelected

    - OnSelect: UpdateContext({expandCollapse:false})

    2. for the 'Down' (expand) button:

    - Visible: Not(expandCollapse && ThisItem.IsSelected)

    - OnSelect: UpdateContext({expandCollapse:true})

    Then on the second gallery set the Height to be If(expandCollapse && ThisItem.IsSelected,190,0) - adjust to your needs.

     

    This should create a basic accordion gallery with minor tweaks to reflect your data sources. 

     

    Hope this makes it clearer 🙂 

     

     

  • Hockeyman9474 Profile Picture
    110 on at

    Followed all instructions and expand button not visible now and collapse does nothing when I click on it. To follow th eloginc:

    We created a gallery and a sub gallery both blank,auto scaling. We added to buttons and renamed them expand and collapse. This is where I get lost. We use "NOT" as a means of saying do not show? Before renamingicons i noticed the expandCollapse didn't show as an option. Does the smart function combine the two? Also, what purpose does the timer serve? Shouldn't we have the timer set to true when I click the expand? Logic also leads me to belive the timer should be set to true when I expand, but then again, I don't understand the concept of the timer.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have just created a new app and followed the above instructions andI have found the problem - the visible functions needs to be the other way around:

    The expand button will have: Not(expandCollapse && ThisItem.IsSelected)

    and the collapse button will have: expandCollapse && ThisItem.IsSelected

     

    ex.png

     

    The 'expandCollapse' is a context variable that gets created and updated through UpdateContext function, it can be name anything.

    The NOT helps to negate the validation, so only one button is visible at a time. 

     

    I'm not sure on the timer either, I think it has more to do with the animation than with the collapse/expand function as I have manage to create it witouth it.

     

    Let me know if this works 🙂 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have just created a new app and followed the above instructions and have found the problem - the visible functions needs to be the other way around:

    The expand button will have: Not(expandCollapse && ThisItem.IsSelected)

    and the collapse button will have: expandCollapse && ThisItem.IsSelected

     

    ex.png

     

    The 'expandCollapse' is a context variable that gets created and updated through UpdateContext function, it can be name anything.

    The NOT helps to negate the validation, so only one button is visible at a time. 

     

    I'm not sure on the timer either, I think it has more to do with the animation than with the collapse/expand function as I have manage to create it without it.

     

    Let me know if this works 🙂 

  • Hockeyman9474 Profile Picture
    110 on at

    one more thing to consider:

     

    the collapse button has two sets of visible and on select values. Which do I follow. I'm going to write this out, please correct:

     

    Collapse Button

    Visible: expandCollapse && ThisItem.IsSelected)

    OnSelect: UpdateContext ({startTimer:true});UpdateContext{(expandCollapse:false)}

     

    correct?

  • Hockeyman9474 Profile Picture
    110 on at

    Incredible it worked. Will you kindly reply one last time explaining each step so I understand as opposed to just doing what you say to do.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Hockeyman9474
    Sorry I didn't realise I have put the formulas twice for the collapse button, I have now edited the answer.

    So the basic understanding behind all these steps is that a button will be visible when the other one is not - which is achieved by using the "Not" for one of the buttons, based on the current state of the gallery - so if the gallery is expanded then the collapse button is shown and the other way around, when the gallery is collapsed the collapse button is shown.
    The gallery state is determined by the 'expandCollapse' variable which when set to true means the gallery is expanded and when is false the gallery is collapsed. This variable can be named anything - is you who creates it and who updates it. 
    The ThisItem.IsSelected ensures that the item that has been selected is the one who expands/collapse, otherwise when clicking on one of the items, all the rest will expand/collapse - the 'expandCollapse' value being set on all of them.

    Hope this helps 🙂


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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard