I've created a lookup function to set a variant. I want to set the variable to the first letter placed in a text box if it does not contain a P or the first 2 letters in the variable if it does. This is my formula:
THANK YOU!!!! Life saver!
Yes, got it...so change to:
With({_val:Left(Upper('EventSiteCode-TotalContact'.Text),2)},
If(StartsWith(_val, "P"), _val, Left(_val, 1))
)
This is they way I need it.
(if the result (_val) starts with "P", then return just the 2 character, otherwise return the 1 characters.)
So can I just change the 1 to a 2? But that won't help with the ones that I only need 1 character. I need 2 characters if it's a P otherwise just 1 character.
The formula already accounted for that.
With({_val:Left(Upper('EventSiteCode-TotalContact'.Text),2)},
If(StartsWith(_val, "P"), Left(_val, 1), _val)
)
In general it reads like this:
First, get the first 2 characters of the EventSiteCode-TotalContact (we only ever care about 2 characters).
Then if the result (_val) starts with "P", then return just the first character, otherwise return the 2 characters.
So, unless I am completely misunderstanding what you are saying, the provided formula should be giving you what you want.
Thank you for this. I need my variable to be 2 characters if the text in EventSiteCode starts with a P and only 1 character if it starts with anything else.
So do I just flip your formula?
With({_val:Left(Upper('EventSiteCode-TotalContact'.Text),1)},If(StartsWith(_val,"P",Left(_val,2),_val))
I tried this and it didn't work. 😞
Not sure of the value the variable will bring to you, but in general, your formula should be the following:
With({_val:Left(Upper('EventSiteCode-TotalContact'.Text),2)},
If(StartsWith(_val, "P"), Left(_val, 1), _val)
)
I hope this is helpful for you.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.