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 / How to display only fe...
Power Apps
Answered

How to display only few (5-8 records) items in gallery and rest of the items via link button?

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I have gallery control displaying all items from the CDS entity "Entity 1", while my objective is as follows:

 

display first 6 items of the "Entity 1" and then at bottom inside the gallery display button "View More" which should expand rest of the items.

 

when the items are expanded, user should see another button called "View Less" inside the gallery at bottom.

 

How can I achieve this?

 

Thank you!

 

 

Categories:
  • KrishnaV Profile Picture
    5,023 on at

    Hi @dave8 ,

     

    Hmm this is a strange requirement because in PowerApp Gallery will be used to show all the items from the data source or from a Filter. Follow the below steps to achieve this:

    1. Add a gallery in powerApp
    2. Associate the data source in items
    3. Select the gallery and on the visible property of the gallery item apply the below formula
      if(CountRows(gallery.allitems>5 And !varshowAll, false,true)
    4. Now add a hyperlink in the gallery item
    5. Text property apply below formula
      if(CountRows(gallery.allitems>5 , "Show Less","Show More")
    6. OnSelect property apply the below formula
      UpdateContext({varshowAll:!varshowAll})

     

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @dave8 :

    I suggest you use the FirstN function to control the number of items displayed in the Gallery.I've made a test for your reference:

    1\Add a button and set it's

    OnSelect

     

    UpdateContext({var:!var}) /*var is my costom variable*/

     

    Text

     

    If(var,"View Less","View More")

     

    2\Set the Gallery's Items property to:

     

    If(
     var,
     Enity1,
     FirstN(Enity1,6)
    )

     

     80.gif

    Best Regards,

    Bof

  • Dave Wi Profile Picture
    on at

    Hi @v-bofeng-msft 

     

    Your approach makes sense, however I already have if condition applied on items property of the gallery. Therefore, I am confused, how do I make both if condition working for the gallery.

     

    For example, current gallery items formula is as follows:

     

    If( varB=true,Filter(SortByColumns(Search(EntityA...))),SortByColumns(Search(EntityA...)))

     

    How do I integrate your formula in the existing IF condition of gallery items ?

     

    Thanks,    

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    What i was looking for and thank you so much

     

     

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @dave8 :

    You just need to replace Entity1 with your formula.For example:

    If(
        var,
        If( varB=true,Filter(SortByColumns(Search(EntityA...))),SortByColumns(Search(EntityA...))),
        FirstN(If( varB=true,Filter(SortByColumns(Search(EntityA...))),SortByColumns(Search(EntityA...))),6)
    )

    Best Regards,

    Bof

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    Thanks for code but i am having hard time to use it with my exiting gallery item property code can you help please, here is my 

     

    Sort(
    AddColumns(
    GroupBy(
    AddColumns(
    If(
    FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
    Filter(
    colChecks,
    Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year
    ),
    FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
    Filter(
    colChecks,
    searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year
    ),
    FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
    colChecks,
    FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
    Filter(
    colChecks,
    FilterGalStatus_2.Selected.Value
    )
    ),
    "Comppanyvalue",
    Business_x0020_Name
    ),
    "Comppanyvalue",
    "NewGroup"
    ),
    "Status",
    First(
    Sort(
    NewGroup,
    Status.Value,
    Descending
    )
    ).Status.Value,
    "Comments",
    First(
    Sort(
    NewGroup,
    Note,
    Descending
    )
    ).note,
    "Modified",
    First(
    Sort(
    NewGroup,
    Modified,
    Descending
    )
    ).Modified,
    "PhoneNum",
    First(
    Sort(
    NewGroup,
    Title,
    Descending
    ).Title
    ),
    "Collect",
    First(
    Sort(
    NewGroup,
    Month_x0020_and_x0020_Year,
    Descending
    ).Month_x0020_and_x0020_Year
    ),
    "CHECKDUE",
    First(
    Sort(
    NewGroup,
    Date_x0020_due,
    Descending
    )
    ).Date_x0020_due,
    "Pending Invoices",
    CountRows(NewGroup),
    "Invoice",
    First(
    Sort(
    NewGroup,
    Invoice_x0020_Number,
    Descending
    )
    ).Invoice_x0020_Number,
    "TotalBalance",
    Sum(
    NewGroup,
    amount
    ),
    "SumShippingFee",
    Sum(
    NewGroup,
    amount
    ),
    "InvoiceCreated",
    First(
    Sort(
    NewGroup,
    Created,
    Descending
    )
    ).Created
    ),
    CHECKDUE,
    Descending
    )

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Ramole :

    Could you create a new post for this quesetion?

    Generally, we recommend that the post only discuss one question, which is beneficial to other users in the forum to search for the correct answer.

    Best Regards,

    bof

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    I have created a new post for this quesetion

     

    please help 

     

    thanks 

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard