cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## Sequencing using letters and numbers

I have a requirement to create a form where a job number follows on from the last one in sequential order.

However the job numbers are two letters and a number up to 99 e.g. AB99 would then become AC01.

I know there is a sequence function but I'm not sure it can do anything this complex. Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

hi @Anonymous

You can play with this (im lazy i think - friday you know):

you have 4 character (string|string|int|int)

the first two can be counted with base 64 for upper case letter ok

the last tow as integers

Set(varCounter, 1299)

Add a label and set it to the below

``````With(
{
_base: Split(varCounter,"")
},
Char(64 + Index(_base,1).Result) &
Char(64 + Index(_base,2).Result) &
Index(_base,3).Result &
Index(_base,4).Result
)``````

response:

Char(64 + Index(_base, 1).Result) = A

Char(64 + Index(_base, 2).Result) = B

Index(_base, 3).Result = 9

Index(_base, 4).Result = 9

When you add 1 it becomes AC00 (you can add how to go to AC01 im sure)

and as you add it will just increase.

Example:

Hope it helps,

R

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.
7 REPLIES 7
Super User

hi @Anonymous

You can play with this (im lazy i think - friday you know):

you have 4 character (string|string|int|int)

the first two can be counted with base 64 for upper case letter ok

the last tow as integers

Set(varCounter, 1299)

Add a label and set it to the below

``````With(
{
_base: Split(varCounter,"")
},
Char(64 + Index(_base,1).Result) &
Char(64 + Index(_base,2).Result) &
Index(_base,3).Result &
Index(_base,4).Result
)``````

response:

Char(64 + Index(_base, 1).Result) = A

Char(64 + Index(_base, 2).Result) = B

Index(_base, 3).Result = 9

Index(_base, 4).Result = 9

When you add 1 it becomes AC00 (you can add how to go to AC01 im sure)

and as you add it will just increase.

Example:

Hope it helps,

R

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.
Anonymous
Not applicable

This looks amazing @rubin_boer . Not at all lazy...I will have a play and let you know how it turns out. Thank you.

Anonymous
Not applicable

@rubin_boer this has been a great starting point thanks. I've familiarised myself with ASCII and have had a play around. However, I haven't worked out how to convert back from my job number e.g. AB99 to 1299.  I can see how to do it using the full 255 character code but not starting from 64. I'll be taking the value from the last job number listed.

Any ideas how to do this?

Super User

hi @Anonymous

here is a way:

this code can be used where you wish and in this example i use a button. Coalesce(Index(_getChars, 2).number,Index(_getChars, 1).number) is used for when the two characters are the same in which case the filter will return 1 row

``````UpdateContext({jobnumber: "AB99"});
UpdateContext({convertedJobnumber:
With(
{
_getNums: Split(jobnumber,""),
_getChars:
Filter(
ForAll(
Sequence(26),
{
number: Value,
character: Char(Value + 64)
}
),
character in Left(jobnumber,2)
)
}
,
Index(_getChars, 1).number & Coalesce(Index(_getChars, 2).number,Index(_getChars, 1).number) & Index(_getNums, 3).Result & Index(_getNums, 4).Result
)
}
)``````

Result (i used the text input to set that variable jobnumber)

Hope it helps,

R

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.
Anonymous
Not applicable

Thank you...that works!

Anonymous
Not applicable

Right so I had to make a couple of tweaks because the length of varCounter may be 5 or 6 characters depending on the letters e.g. JJ27 would be 101027. This is my adapted code where varNewJob replaces varCounter and varLength is Len(varNewJob):

``````Switch(varLength, 4,
With(
{
_base: Split(varNewJob,"")
},
Char(64 + Index(_base,1).Result) &
Char(64 + Index(_base,2).Result) &
Index(_base,3).Result &
Index(_base,4).Result
), 5,
With({_base: varNewJob} ,
Char(64 + Left(_base, 1)) &
Char(64 + Mid(_base, 2, 2)) &
Right(_base, 2)
),
6,
With({_base: varNewJob} ,
Char(64 + Left(_base, 2)) &
Char(64 + Mid(_base, 3, 2)) &
Right(_base, 2)
)
)``````

``If(Right(varConvertedJob, 2) = "99", Set(varNewJob, varConvertedJob +2), Set(varNewJob, varConvertedJob +1))``

Seems to be working well. Thanks again @rubin_boer .

Super User

sweet stuff, im glad it got you going. i do like the additions 😉

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!