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 / Expand/Collapse - Powe...
Power Apps
Answered

Expand/Collapse - PowerApps Nested gallery (Being able to expand multiple Nested-galleries at the same time)

(0) ShareShare
ReportReport
Posted on by 62

I have a PowerApps Canvas App with a gallery and a nested gallery / sub-gallery, using SharePoint as my data source.
I use a drilldown-Icon to expand the sub-gallery when I click on the drilldown-Icon. My problem is that I am only allowed to expand a single sub-gallery at a time. I need to be able to expand and collapse whichever sub-galleries I choose (i.e., expand multiple nested-galleries simultaneously).

Can anyone please help me solve this issue?

The formulas I use now where I'm only allowed to expand one single sub-gallery at a time is;


Drilldown-Icon (OnSelect): 

 

 

Select(Parent);Set(varGlrGoal, glrGoal.Selected.Goal)

 

 


Parent Gallery (items): 

 

 

Filter(FP_ForretningsplanerGoal, Forretningsplan = varRecord.Title)

 

 


Nested gallery / sub-gallery (items): 

 

 

SortByColumns(Filter(FP_ForretningsplanerInnhold, Goal = varGlrGoal), "Status0", Descending)

 

 

 

Nested gallery / sub-gallery (Height): 

 

 

If(CountRows(glrResultater.AllItems) > 0, CountRows(glrResultater.AllItems) * 90, 0)

 

 

 

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    I cam point you in the right direction and I can point out why it is performing the way it is.

     

    When your Parent gallery's drilldown item is selected, you are selecting that row within that gallery and then setting it to a variable, so every time you click another icon, you are selecting that particular row and setting the variable again, so it is resetting to the new selection.

     

    I think if you instead started collecting the rows of the selected items into a collection (containing the row ID) and then had your sub-gallery based on whether a row's ID appeared within that collection then you could have expanding sub-galleries that remain open. Then have your drilldown icon OnSelect check if an item already exists in that collection by ID, if yes then remove it, otherwise add it to the collection.

  • Linn93 Profile Picture
    62 on at

    Thanks @iAm_ManCat,

    I'm not sure if I understand exactly how I should create your recommendation, as I am quite new to PowerApps.
    I attempted the following;


    ParentGallery - Onselect:

    if(countrows(filter(selectedResultaterID,glrGoal=ThisItem.glrGoal))=0,Collect(selectedResultaterID,{glrGoal:ThisItem.glrGoal}),Remove(selectedResultaterID,glrGoal=ThisItem.GlrGoal)))
    

    NestedGallery-Height:

    countrows(filter(selectedResultaterID,grlGoal=ThisItem.glrGoal))

    And everything fails.
    Not sure if I understand correctly what the row ID is? What is the correct variable for this? Are you able to help med with the approach to achieve this?

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hi!

     

    Every row in a SharePoint list or library has a unique row ID columns called "ID", so you can collect these to identify which specific row of data you are referring to, however you need a reference to that ID in any child lists by adding a column like ParentID to relate that row to, which I believe you have done the same thing with the 'goal' field in both lists..

     

    Drilldown-Icon (OnSelect), changed to collect or remove items:

    Select(Parent);
    If(
     CountRows(
     LookUp(col_ParentGoals,Goal = glrGoal.Selected.Goal)
     =0
     ),
    
     // If not in collection then collect
     Collect(col_ParentGoals, glrGoal.Selected),
    
     // If already in collection then remove
     Remove(col_ParentGoals, glrGoal.Selected)
    )



    Parent Gallery (items), same as you had it: 

    Filter( FP_ForretningsplanerGoal, Forretningsplan = varRecord.Title )



    Nested gallery / sub-gallery (items), changed to check if that  Goal appears in the collection of Goals:  

    SortByColumns(
     Filter(
     FP_ForretningsplanerInnhold,
     Goal in col_ParentGoals.Goal
     ),
     "Status0", 
     Descending
    )



    Nested gallery / sub-gallery (Height), same as you had it:

    If(
     CountRows(glrResultater.AllItems) > 0,
     CountRows(glrResultater.AllItems) * 90,
     0
    )

     

  • Linn93 Profile Picture
    62 on at

    Thank you so much for your help @iAm_ManCat ,

    I attempted the formulas you suggested. It works except for the Drilldown-Icon (OnSelect).

     

    Select(Parent);
    If(
     CountRows(
     LookUp(col_ParentGoals,Goal = glrGoal.Selected.Goal)
     =0
     ),
    
     // If not in collection then collect
     Collect(col_ParentGoals, glrGoal.Selected),
    
     // If already in collection then remove
     Remove(col_ParentGoals, glrGoal.Selected)
    )

    The issue I'm facing is "Invalid argument type".

    Do you have any idea what I might be doing wrong and how I can make it work?

    DrilldownIcon Onselect.png
    Issue onselect.png
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Yes, I think I misplaced a bracket on the 6th line, that should've been before the equals zero!

     

    
    Select(Parent);
    If(
     CountRows(
     LookUp(col_ParentGoals,Goal = glrGoal.Selected.Goal)
     )=0
     ,
    
     // If not in collection then collect
     Collect(col_ParentGoals, glrGoal.Selected),
    
     // If already in collection then remove
     Remove(col_ParentGoals, glrGoal.Selected)
    )

     

  • Linn93 Profile Picture
    62 on at

    I'm still not able to make it work with the formula you suggested. The Issue I'm facing in the App Checker now are "Invalid argument type(Record). Expecting a Table value instead". 

    Select(Parent);
    If(
     CountRows(
     LookUp(col_ParentGoals,Goal = glrGoal.Selected.Goal)
     )=0
     ,
    
     // If not in collection then collect
     Collect(col_ParentGoals, glrGoal.Selected),
    
     // If already in collection then remove
     Remove(col_ParentGoals, glrGoal.Selected)
    )


    I tried with the following formula for the Drilldown-Icon (On select);

    Select(Parent);
    If(
     CountRows(
     Filter(
     col_ParentGoals,
     Goal = glrGoal.Selected.Goal
     )
     ) = 0,
     Collect(
     col_ParentGoals,
     {Goal: glrGoal.Selected.Goal}
     ),
     Remove(
     col_ParentGoals,
     Filter(
     col_ParentGoals,
     Goal = glrGoal.Selected.Goal
     )
     )
    )


    Which does work, and the issue in the "App checker" disappeared. But I'm still only able to expand one nested gallery at the time, and not multiple as I need it to be.

  • Linn93 Profile Picture
    62 on at

    I'm still not able to make it work with the formula you suggested. The Issue I'm facing in the App Checker now are "Invalid argument type(Record). Expecting a Table value instead". 

    Select(Parent);
    If(
     CountRows(
     LookUp(col_ParentGoals,Goal = glrGoal.Selected.Goal)
     )=0
     ,
    
     // If not in collection then collect
     Collect(col_ParentGoals, glrGoal.Selected),
    
     // If already in collection then remove
     Remove(col_ParentGoals, glrGoal.Selected)
    )



    I tried with the following formula for the Drilldown-Icon (On select);

    Select(Parent);
    If(
     CountRows(
     Filter(
     col_ParentGoals,
     Goal = glrGoal.Selected.Goal
     )
     ) = 0,
     Collect(
     col_ParentGoals,
     {Goal: glrGoal.Selected.Goal}
     ),
     Remove(
     col_ParentGoals,
     Filter(
     col_ParentGoals,
     Goal = glrGoal.Selected.Goal
     )
     )
    )


    Which does work, and the issue in the "App checker" disappeared. But I'm still only able to expand one nested gallery at the time, and not multiple as I need it to be.

  • Verified answer
    Linn93 Profile Picture
    62 on at

    I just wanted to update this post.

    I figured out the solution on how to expand multiple nested galleries simultaneously.

    I did the following;

    Drill-down-Icon (On select):

    Select(Parent); If( CountRows( Filter( col_ParentGoal, Goal = glrGoal.Selected.Goal ) ) = 0, Collect( col_ParentGoal, {Goal: glrGoal.Selected.Goal} ) )

     

    Drill-down-Icon (Visible):

    !drillUpIcon.Visible

    Drill-UP-Icon (On select);

    Select(Parent); Remove( col_ParentGoal, Filter( col_ParentGoal, Goal = glrGoal.Selected.Goal) )

     

    Drill-UP-Icon (Visible):

    If(ThisItem.Goal in col_ParentGoal, true, false)

     

    Parent Gallery (items):

    Filter(FP_ForretningsplanerGoal, Forretningsplan = varRecord.Title)

     

    Nested gallery / sub-gallery (items):

    SortByColumns( Filter( FP_ForretningsplanerInnhold, Goal in col_ParentGoal, Goal = lblGoal.Text ), "Status0", Descending )

     

    Nested gallery / sub-gallery (Height):

    If(CountRows(glrResultater.AllItems) > 0, CountRows(glrResultater.AllItems) * 64, 0)

     

    Nested gallery / sub-gallery (Visible):

    If(ThisItem.Goal in col_ParentGoal, true, false)


    Thank you @iAm_ManCat, I wouldn't have figured out the solution without your help.

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 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard