function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ajay Kumar 261Ajay Kumar 261 

Can this formula be optimized?

Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay
Best Answer chosen by Ajay Kumar 261
FearNoneFearNone

Hi Ajay,

since it seems there is a pattern with your conditions, perhaps you could use 'LEN':
CASE( LEN(MS_Score__c) ,
  1, Profile_Score__c +MS_Score__c,
  2, Profile_Score__c +RIGHT(MS_Score__c,1),
...
)

Fernand

All Answers

FearNoneFearNone

Hi Ajay,

since it seems there is a pattern with your conditions, perhaps you could use 'LEN':
CASE( LEN(MS_Score__c) ,
  1, Profile_Score__c +MS_Score__c,
  2, Profile_Score__c +RIGHT(MS_Score__c,1),
...
)

Fernand
This was selected as the best answer
Ajay Kumar 261Ajay Kumar 261
That was perfect answer Fernand. Thank you so much.
Ajay Kumar 261Ajay Kumar 261
Can you help me with this also:) Sorry to trouble you. if we can optimize?

Case(Score_Merchant__c, 
"A4",7, 
"B4",7, 
"C4",5, 
"D4",4, 
"A3",8, 
"B3",7, 
"C3",6, 
"D3",5, 
"A2",9, 
"B2",8, 
"C2",8, 
"D2",8, 
"A1",10, 
"B1",9, 
"C1",9, 
"D1",8, 
"A0",7, 
"B0",6, 
"C0",4, 
"D0",3, 
"E0",3, 
"U0",4, 
"E1",8, 
"E2",8, 
"E3",5, 
"E4",4, 
"U1",9, 
"U2",8, 
"U3",6, 
"U4",5, 
0)
FearNoneFearNone
hi Ajay,

I can't really see any pattern, so i think that that's it.
and you might wanna post this as a new thread so that others may help.

cheers
VIGNESH BALASUBRAMANIANVIGNESH BALASUBRAMANIAN
Hi Ajay,

I think you expecting this one,Take a look at this....,
 
CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
Profile_Score__c +RIGHT(MS_Score__c,1))

Thanks & Best Regards,
Vignesh.B