Greetings:
I'm an experienced programmer but brand new to Power Automate so I'm experiencing the usual frustrations with something that is very easy on one platform/language taking hours and and hours of frustration to accomplish on another.
I have a very simple objective: left padding a number (x) with '0' based on it's value so that:
* if x <10 then the string value of x should be '00X', e.g., '009
* if x <100 then the string value of x should be '0X', e.g., '046'
* otherwise the string value of x should be 'X', e.g., '238', '1479', etc.
where X is the string value of the integer x.
To me this is a classic case where a switch statement would be used to reset the value of the variable X. For example, in the case where x <10 I would write X= concat('00',X) and etc. with the other cases. This doesn't work because, apparently in Power Automate, you can't assign a value to a variable that refers to the existing value of that variable (a simple assignment statement in other languages). Even if I use a different variable name I'm still running into issues with using the concat function when setting a variable.
I've had better luck with concat when using Compose instead of Set Variable. However, the problem there is that you can only assign a 'compose' output name in one action. This doesn't work in the Case branches of a Switch statement. Compose actions, and the outputs that bear their name, appear to be unique. So how do you come out of a switch statement like this with a single variable that is padded with '00' or '0' or '' based on the input value if each Compose action has to have a unique name?
Again, I'm brand new at this, but what would take me, say, 5 seconds to solve in Python has taken me 5 hours in Power Automate and I still haven't solved it! Any help would be appreciated!
Thanks, in advance.