Kuroshi Posted July 12, 2019 Report Share Posted July 12, 2019 I have a formula in my table. CASE WHEN [@field:UserName] = 'Emp' THEN 'Employee' ELSE 'Manager' I wanted to make that if UserName starts with Emp then it is employee otherwise Manager Quote Link to comment Share on other sites More sharing options...
0 Barbie Posted July 12, 2019 Report Share Posted July 12, 2019 Hi, please try this instead:CASE WHEN [@field:UserName] LIKE '%Emp'THEN 'Employee'ELSE 'Manager' END hope this works -Barbie Quote Link to comment Share on other sites More sharing options...
0 DefinitelyNot31337 Posted July 23, 2019 Report Share Posted July 23, 2019 Hello @Barbie, If you are working with big data, you may want to use the syntax below instead. It works well with your requirement and runs much faster on a database standpoint. CASE WHEN LEFT([@field:usz], 3) = 'Emp' THEN 'Employee' ELSE 'Manager' END Hope this helps -DN31337! Quote Link to comment Share on other sites More sharing options...
0 Flowers4Algernon Posted October 16, 2021 Report Share Posted October 16, 2021 Hello, just wanted to share this Function Reference that will be definitely a big help on calculations: https://howto.caspio.com/function-reference/ Quote Link to comment Share on other sites More sharing options...
0 Queso Posted July 21, 2022 Report Share Posted July 21, 2022 Thank you for the suggestions. I tried the solutions above. It seems that Barbie's solution outputs a 'Yes' if the text 'emp' is placed anywhere on the username. But for DefinitelyNot31337's solution, it outputs a 'Employee' if the username starts with 'emp'. Solutions are great so I utilized them both. Here is a reference as well: https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/#:~:text=Birth. Learn more.-,Conditional Cases in Calculated Fields,-You can use Quote Link to comment Share on other sites More sharing options...
0 Wikiwi Posted July 21, 2022 Report Share Posted July 21, 2022 @trickson you can also try Charindex() for this. Charindex will output the starting point of the string or the character that you are looking for and if that value is greater than 0 that means that there is an Emp in the string. CASE WHEN Charindex('Emp',[@field:Name]) > 0 THEN 'Employee' ELSE 'Manager' END Quote Link to comment Share on other sites More sharing options...
0 GoodBoy Posted July 21, 2022 Report Share Posted July 21, 2022 Hello! Another approach is by using the SUBSTRING function to check if the 1st three letters of the field is 'Emp'. CASE WHEN SUBSTRING([@field:UserName], 1, 3) = 'Emp' THEN 'Employee' ELSE 'Manager' END Quote Link to comment Share on other sites More sharing options...
Question
Kuroshi
I have a formula in my table.
CASE WHEN [@field:UserName] = 'Emp'
THEN 'Employee'
ELSE 'Manager'
I wanted to make that if UserName starts with Emp then it is employee otherwise Manager
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.