cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tagustin2020
Impactful Individual
Impactful Individual

Abbreviate Long Names, substitute ...

@RandyHayes 

 

Hello Randy,

 

I'm really short on space in my gallery so I'm trying to figure out how to shorten long company names as I don't want to word wrap/increase height of gallery row/go with a flexible height gallery.

 

Left(Substitute(ThisItem.Company,"",""),20)&If(Len(Substitute(ThisItem.Company,"","")) >20,"...","")

 

The following formula results in this appearance which isn't attractive. Is there anything I can do to the formula to make it look better? In this example, the full name of the company is Tektronix Component Solutions. Thanks Randy! Teresa

 

LongNameSS.png

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@tagustin2020 

Turn the Wrap property off (false).  It will then automatically truncate.

 

However, If I recall property, your items are not Labels but are TextInput Controls set to View mode.

So, in that case, you can set to the following in the Default property:

If(Self.DisplayMode=DisplayMode.View, With({_t: ThisItem.Company}, Left(_t, 20) & If(Len(_t)>20, "...")), ThisItem.Company)

I am not sure what you were trying to do with the substitute function by replacing "" with "".

 

The above formula should give you what you need for the view mode and edit mode as well.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

8 REPLIES 8
RandyHayes
Super User III
Super User III

@tagustin2020 

Turn the Wrap property off (false).  It will then automatically truncate.

 

However, If I recall property, your items are not Labels but are TextInput Controls set to View mode.

So, in that case, you can set to the following in the Default property:

If(Self.DisplayMode=DisplayMode.View, With({_t: ThisItem.Company}, Left(_t, 20) & If(Len(_t)>20, "...")), ThisItem.Company)

I am not sure what you were trying to do with the substitute function by replacing "" with "".

 

The above formula should give you what you need for the view mode and edit mode as well.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

@RandyHayes 

 

Hi Randy,

 

Thanks! That did the trick. My home screen has labels in it. I was using a formula that was provided to me in the Community Forum for the Tool Design Center app. Can I use the Default formula you provided to me in the Text property of the label or is there some other variation of the Text formula I provided above that I should use instead?

 

NameFixSS.png

RandyHayes
Super User III
Super User III

@tagustin2020 

Always happy to help!! 😁

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 

 

Hi Randy,

 

Thanks again for your help. Since my label is read-only, I pasted this formula into the Text property.

With({_t: ThisItem.Company}, Left(_t, 20) & If(Len(_t)>20, "..."))

 

I have a related question in regards to a people name label. The label displays my name fine, Teresa Agustin, but not my colleague's name which has a space in it, Howard De Leon. Howard will be a heavy user of the app and we have a few other people with a space in their last name so I'm wondering if there is something we can add to the formula above that will account for this. Thank you! Teresa

 

NameSpaceIssue.png

 

RandyHayes
Super User III
Super User III

@tagustin2020 

This is coming from your Items property of the Gallery.  In there you are adding a column that formats the names of users.  If I recall correctly, it was the space (assumed to be between the first and last name) of the display name that gave the output you wanted in your other apps.

Do you think it is possible that Howard would consider changing his last name??  LOL  😂🤣  Sorry, couldn't resist.

 

Looking at a formula for one of the other apps, we have this part in it:

        "requestors", With({lName: Split('Requestor Name'.DisplayName, " ")},
                   First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & "."
                 )

I don't believe this part is the same as the formula in your current items property, but that is the place to look.

 

The formula in the With there needs to be changed to the following:

First(lName).Result & If(CountRows(lName)>2, " " & Last(FirstN(lName, 2)).Result) & " " & Left(Last(lName).Result, 1) & "."

 

That should fix it.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 

 

Hi Randy,

 

The Shipping guys floated the idea of Howard changing his name too 😄

 

I'm messing up the brackets and parentheses somehow. What am I getting wrong?

 

Gallery Items formula:

        "requestors", With({lName:First(lName).Result & If(CountRows(lName)>2, " " & Last(FirstN(lName, 2)).Result) & " " & Left(Last(lName).Result, 1) & "."),
        "logistics", If(IsBlank('Logistics Staff Member'.DisplayName), 
        "pending", With({lName: Split('Shipped By'.DisplayName, " ")},
                    First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & ".")),
        "stat", Status.Value,
        "method", 'Shipping Method'.Value
    )},

 

Screenshot:

longnameerror.png

 

Thanks,

Teresa

RandyHayes
Super User III
Super User III

@tagustin2020 

No, I meant the part in the With...not the scoped variable of the with. 

The scoped variable is :  {lName: Split('Requestor Name'.DisplayName, " ")} we need that still.

So your formula snippet should be:

        "requestors", With({lName: Split('Requestor Name'.DisplayName, " ")}, 
             First(lName).Result & If(CountRows(lName)>2, " " & Last(FirstN(lName, 2)).Result) & " " & Left(Last(lName).Result, 1) & "."
             ),
        "logistics", If(IsBlank('Logistics Staff Member'.DisplayName), 
        "pending", With({lName: Split('Shipped By'.DisplayName, " ")},
                    First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & ".")),
        "stat", Status.Value,
        "method", 'Shipping Method'.Value
    )},

  

See where that gets you and if still problems, put the pressure on Howard for that name change 🤣

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 

 

Hi Randy,

 

Unfortunately it didn't work. If Howard isn't willing to change his name to his wife's maiden name, I think we may have to live with De L. Since he is a frequent shipper, I'm sure the Logistics Crew will recognize that abbreviation. Thanks for trying! I really appreciate you helping me figure out how to abbreviate company names that run long. I'm going to mark that post as a solution. Have a great day!

 

Teresa

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,663)