Say I have a string P001 in a Context variable, how can I get the number 001 and assign it back to that context variable?
Solved! Go to Solution.
Hi @Marini83 ,
Do you want to extract the Number value from a Text string?
Based on the needs that you mentioned, I think the Substitute function could achieve your needs. I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Initialize" button to following:
UpdateContext({ContextVar1: "P001"})
Set the OnSelect proeprty of the "Extract Number" button to following:
UpdateContext({ContextVar1: Substitute(ContextVar1, "P","")}) /* <-- On your side, you should take a try with this formula to achieve your needs */
Set the Text property of the Label to following:
"Current Context Variable value: " & ContextVar1
Please check the following GIF screenshot for more details:
Best regards,
Hi @Marini83
Just to clarify, will your input value always be in the format - 1 alpha character followed by 3 numbers? Or will the preceding number of characters before the number variable?
Hi,
If the syntax is always PXXX, you can do like that :
Set(VAR, Value(Right(YourString,3)))
Best regards,
Louis
Presumably yes , It should be in that format.
Then you can process as I explained, and put the code in the OnSelect property of a Button, for example.
BR,
Louis
Hi @Marini83 ,
Do you want to extract the Number value from a Text string?
Based on the needs that you mentioned, I think the Substitute function could achieve your needs. I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Initialize" button to following:
UpdateContext({ContextVar1: "P001"})
Set the OnSelect proeprty of the "Extract Number" button to following:
UpdateContext({ContextVar1: Substitute(ContextVar1, "P","")}) /* <-- On your side, you should take a try with this formula to achieve your needs */
Set the Text property of the Label to following:
"Current Context Variable value: " & ContextVar1
Please check the following GIF screenshot for more details:
Best regards,
UpdateContext({VariableName:"P001"});
UpdateContext({VariableName: Mid(VariableName,2)})
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
185 | |
53 | |
41 | |
37 | |
31 |
User | Count |
---|---|
246 | |
75 | |
71 | |
69 | |
65 |