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 / Variable Label width w...
Power Apps
Answered

Variable Label width within Gallery

(0) ShareShare
ReportReport
Posted on by 21

Hello all,

 

I'm not sure if this is even possible, but I'm trying to do the following: I have a Gallery with a Header Label, which gets the labels from a table. I would like each instance of this label to have a variable width.

 

The values it gets from this table are: Name, Type, Date and Status. I would like the Name label/column to be 3x the size of the others.

Categories:
I have the same question (0)
  • VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    Hi @sweetpickleduck ,

     

    You can achieve what you want.
    - store the default size of labels in a context variable: 
    UpdateContext({ctx_LabelWidth: 100});  //modify this to suit desired size
    - set Width property of the label from the gallery to:
    If(ThisItem.Text in ["Name", "Type", "Date" , "Status"], 3*ctx_LabelWidth, ctx_LabelWidth) //ThisItem.Text replace it with your property

    Good luck

     

  • sweetpickleduck Profile Picture
    21 on at

    Hi @VasileR, thanks for the fast reply!

     

    I forgot to mention that this is in a component library, which to my knowledge doesn't support UpdateContext?

     

    What I have right now is the following:

     

    A table like this:

    Table(
    {
    HeaderLabelID: 1,
    HeaderLabel: "Name",
    FillPortion: 3
    }, {
    HeaderLabelID: 2,
    HeaderLabel: "Type",
    FillPortion: 1
    }, {
    HeaderLabelID: 3,
    HeaderLabel: "Date",
    FillPortion: 1
    }, {
    HeaderLabelID: 4,
    HeaderLabel: "Status",
    FillPortion: 1
    }
    )

     

    Where the FillPortion should make the width. On the label itself I use: Parent.TemplateWidth * ThisItem.FillPortion

     

    With using 20% opacity background I can see that the Name label is indeed 3x the width of the others, but Type is at position X where it would be if Name was only 1x width. It looks as follows:

     

    sweetpickleduck_0-1700129768261.png

     

    Type and Date have a darker background because Name is underneath them.

  • charlessexton Profile Picture
    11 Super User 2024 Season 1 on at

    Is it a variable list of headers or are they always the same? Usually I would use a container for this instead.

     

    charlessexton_0-1700130329705.png

     

  • Verified answer
    VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    I see what you mean now, you need to also calculate X of each gallery label item.

     

    Play around with the following for the label in the gallery:

     X:

     

    Sum(
     Filter(YOUR_TABLE_NAME_HERE, HeaderLabelID < ThisItem.HeaderLabelID), FillPortion) * Parent.TemplateWidth / 5 - If(ThisItem.HeaderLabelID>1, (ThisItem.HeaderLabelID -1) * Parent.TemplateWidth, 0)

     

    Width:

     

    ThisItem.FillPortion * Parent.TemplateWidth / 5

     


    Play with "Parent.TemplateWidth / 5" to achieve the desired scale.

  • sweetpickleduck Profile Picture
    21 on at

    Thanks @charlessexton , the idea is to use this table as a template for 10+ tables that will be in the app. They will all have a different amount of columns and needed size. Then by changing the values in the Table, each can be edited easily.

  • sweetpickleduck Profile Picture
    21 on at

    Thank you very much @VasileR! I'm playing around with it but haven't found the right combination yet.  In the beginning of the X formula you use ID, which ID is that supposed to point to?

  • VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    forgot to edit that also, it is 

    HeaderLabelID

    updated in the above post also

  • sweetpickleduck Profile Picture
    21 on at

    It worked @VasileR! Thank you very much!

  • VasileR Profile Picture
    298 Super User 2024 Season 1 on at

    @sweetpickleduck, nice! I am glad you did it!

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 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard