cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
venka91
Super User
Super User

Split the number from a label

Hi there,

 

i need a help. I have applied some filter for my label text in helpdesk application.

So each label will show the count of ticket numbers.

 

Example : AllTickets(3), Open(5), Rejected(1), Inprogress(3)

 

Now i want to extract the number from the label text. Could you please assist how to do it. I used to Split Function, but i did not get the desired Result.

 

Set(varCount, Split(label1.Text, "(" && ")")

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

@venka91 ,

Oh well it was a good 15 minutes doing some code gymnastics that may be useful for someone . . . you just need this

With(
   {
      wStr: 
      Last(
         Split(
            YourStringHere,
            "("
         )
      ).Result
   },
   Left(
      wStr,
      Len(wStr) - 1
   )
)

 

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

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @venka91 ,

I felt like some burnt brain, so here it is - a Collection

With(
   {
      wItems: 
      Split(
         YourTextHere,
         ","
      )
   },
   With(
      {
         wNos: 
         ForAll(
            wItems,
            Last(
               Split(
                  Result,
                  "("
               )
            )
         )
      },
      ClearCollect(
         colNumbers,
         ShowColumns(
            AddColumns(
               wNos,
               "Number",
               Substitute(
                  Result,
                  ")",
                  ""
               )
            ),
            "Number"
         )
      )    
   )
)

and a label with spaces in between them

With(
   {
      wItems: 
      Split(
         YourTextHere,
         ","
      )
   },
   With(
      {
         wLast: 
         ForAll(
            wItems,
            Last(
               Split(
                  Result,
                  "("
               )
            )
         )
      },
      With(
         {
            wNumbers: 
            AddColumns(
               wLast,
               "Number",
               Substitute(
                  Result,
                  ")",
                  ""
               )
            )
         },
         Concat(
            wNumbers,
            Number & " "
         )
      )
   )
)

 

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

Thank you so much for taking much efforts to derive this formula. However, when put a derived Column "Number" into any label, it is not showing the value. instead it remains as number.

 

I have put your whole formula in a Set whole formula to a set command.

 

Set(varLabelNumber, yourformula)

 

and in a label text i have set the formula as : varLabelNumber.Number

 

But does not get any value. Any feedback.

@venka91 ,
I just ran this and got the expect result

With(
   {
      wItems: 
      Split(
         YourTextHere,
         ","
      )
   },
   With(
      {
         wLast: 
         ForAll(
            wItems,
            Last(
               Split(
                  Result,
                  "("
               )
            )
         )
      },
      With(
         {
            wNumbers: 
            AddColumns(
               wLast,
               "Number",
               Substitute(
                  Result,
                  ")",
                  ""
               )
            )
         },
         Set(
            varLabelNo,
            Concat(
               wNumbers,
               Number & " "
            )
         )
      )
   )
)

 

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

 

venka91
Super User
Super User

could you please tell me which string you are trying to manipulate ?

@venka91 ,

The one you posted

AllTickets(3), Open(5), Rejected(1), Inprogress(3)
venka91
Super User
Super User

Okay, but all this are not in one label. I am extremely sorry if the context of question sounded different to you.

 

There are 4 label controls and its text are

 

AllTickets(3)

Open(5)

Rejected(1)

Inprogress(2)

 

when i click the label control AllTickets(3), i would like to extract the number alone from the string.

Similar way, when i click Open(5), i want 5 to be extracted from this string.

So i am confused, is this require a complex coding ? 

could this possible using Left, Mid or Right functions ?

 

 

@venka91 ,

Oh well it was a good 15 minutes doing some code gymnastics that may be useful for someone . . . you just need this

With(
   {
      wStr: 
      Last(
         Split(
            YourStringHere,
            "("
         )
      ).Result
   },
   Left(
      wStr,
      Len(wStr) - 1
   )
)

 

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

Thank you so much warran.. As usual, you have taught me something new... it worked perfectly.

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 (5,193)