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 / Dynamic Gallery Item H...
Power Apps
Answered

Dynamic Gallery Item Height based on available labels

(0) ShareShare
ReportReport
Posted on by 16

Hello Everyone,

 

I have a task to create a gallery that will show Items and their parameters.

One Item can have 1 to X parameters shown in labels, and only the Name of the items is mandatory, other parameters can be blank.

If a parameter is blank it shows as an empty space in the gallery, this causes me to lose valuable screen space marked red.

 

MarekFe_0-1686929017015.png

I was expecting this to work automatically like it does in FormsViewer with Visible value, content auto adjusts to available space if a card is set visible false..

 

What I managed so far is to automatically position labels based on the Name label, if parameter is empty it moves the label to the corner over Name label, like this:

 

Name = 5

Product type Y =   If(IsBlank('Product type'),Name.Y,Name.Y + Name.Height + 5)

Serial number Y = If(IsBlank('Serial number'),Name.Y,'Product type'.Y + 'Product type'.Height + 5)

SIM No. Y =          If(IsBlank(SIM),Name.Y,'Serial number'.Y + 'Serial number'.Height + 5)

Inventory ID Y =   If(IsBlank(Inventory),Name.Y,SIM.Y + SIM.Height + 5)

Phone No. Y =      If(IsBlank(Phone),Name.Y,Inventory.Y + Inventory.Height + 5)

etc..

 

This setup works fine if each predecesor is not blank as you can see in image Name1 and Name2

But if a parameter somewhere in the middle is empty it brakes all its successors position.

For example Name3 is missing Serial No & Invetory ID, this moves SIM No & Phone No bellow Name3 and above Product type

Or Name4 is missing Serial No & SIM No, this moves Inventory No bellow Name4 and above Product type

 

MarekFe_1-1686929204534.png

 

I think that a solution would be to give every label id based on possition, create a list of not blank ids, calculate their individual height, and then somehow use this data to calculate position of labels based on their predecesors..

But this is too advanced for me.

 

Please help.

Categories:
I have the same question (0)
  • Verified answer
    cmitchener Profile Picture
    on at

    One possibility is to put all of those labels in the same textbox/text label. Take the code below:

     

    Concatenate(

         If(Len(Name) > 0, Concatenate(Name, Char(10)), ""),
         If(Len('Product type') > 0, Concatenate('Product type', Char(10)), ""),

         If(Len('Serial number') > 0, Concatenate('Serial number', Char(10)), "")

         //[etc...]

    )    

     

    Char(10) is PowerApps' way of saying "line break". Each IF statement will check to see if the item you are looking at has more than 0 characters (basically ensuring it isn't empty). If it does, it will pull in that item and a line break; and if not, it will pull in empty text (hence the ""). All you have to do is add more lines of IF statements for every item you might want, but if the texbox or label is set to auto height, it will take care of the rest. Let me know if you have any questions about this.

  • cmitchener Profile Picture
    on at

    Here is a screenshot, and I slightly revised the code to make it shorter

     

    cmitchener_0-1686935345897.png

     

  • MarekFe Profile Picture
    16 on at

    Thank you it works as needed.

  • cmitchener Profile Picture
    on at

    Perfect!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard