cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StephenGW
Post Patron
Post Patron

Custom sort first part of text

Hello,

 

I have an image gallery of attachments Items = LookUp(List,ID=glbCurrentRecord.ID).Attachments

These attachments get these names depending on what they are for, Sort 1 -Now(), Sort 2 -Now(), Set 1 -Now(), Set 2 -Now(), Shine 1 -Now(), Shine 2 -Now() and so on. I want to sort this gallery just in this order Sort (1,2,3,ect), Set (1,2,3,ect), Shine (1,2,3,ect). I think this could be done with something like this.

 

SortByColumn(LookUp(List,ID=glbCurrentRecord.ID).Attachments,Left(DisplayName,Find("-",DisplayName)-1),["Sort","Set","Shine"]) or maybe something with a StartsWith but I can't seem to get it to work.

 

Can someone point me in the right direction?

 

Thanks

3 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @StephenGW ,

Not straight-forward - the below allows for two number spaces (up to 99) and should work as long as a single number has a space after it, I have not tested, so you might have to adjust the number positions slightly

Sort(
   LookUp(
      List,
      glbCurrentRecord.ID
   ).Attachments,
   With(
      {
         wSep: 
         Find(
            "-",
            DisplayName
         )
      },
      Left(
         DisplayName,
         wSep - 1
      ) & 
      Mid(
         DisplayName,
         wSep + 1,
         2
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

Hi @StephenGW ,

A bridge too far . . . it is complex enough just doing it alphabetically.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

StephenGW
Post Patron
Post Patron

@WarrenBelz  I think I figured it out! I was wondering if you could look at this with your expertise and see if there are any potential problems you see with this?

 

SortByColumns(AddColumns(LookUp('5s Audits',ID=glbCurrentRecord.ID).Attachments,"SortName",Left(DisplayName,Find("-",DisplayName)-3)),"SortName",["Sort","Set","Shine","Stand","Sus"])

 

Added a column that only contains the name minus the numbers and anything else then sort by that column. I will try to add another column with the number and use that as the secondary sort?

 

Thoughts?

 

Thanks

View solution in original post

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @StephenGW ,

Not straight-forward - the below allows for two number spaces (up to 99) and should work as long as a single number has a space after it, I have not tested, so you might have to adjust the number positions slightly

Sort(
   LookUp(
      List,
      glbCurrentRecord.ID
   ).Attachments,
   With(
      {
         wSep: 
         Find(
            "-",
            DisplayName
         )
      },
      Left(
         DisplayName,
         wSep - 1
      ) & 
      Mid(
         DisplayName,
         wSep + 1,
         2
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

@WarrenBelz 

 

This appears to sort them by the number at the end. I need the first sort to be in this order Sort, Set, Shine, Stand, Sus and then a second sort by the number. Is this possible?

 

Thanks

Hi @StephenGW ,

A bridge too far . . . it is complex enough just doing it alphabetically.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

StephenGW
Post Patron
Post Patron

@WarrenBelz 

 

Ok, thank you for trying.

StephenGW
Post Patron
Post Patron

@WarrenBelz  I think I figured it out! I was wondering if you could look at this with your expertise and see if there are any potential problems you see with this?

 

SortByColumns(AddColumns(LookUp('5s Audits',ID=glbCurrentRecord.ID).Attachments,"SortName",Left(DisplayName,Find("-",DisplayName)-3)),"SortName",["Sort","Set","Shine","Stand","Sus"])

 

Added a column that only contains the name minus the numbers and anything else then sort by that column. I will try to add another column with the number and use that as the secondary sort?

 

Thoughts?

 

Thanks

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,544)