Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

replacing string

hi guys

i have a few formulas one of them  look like - (sum(x)+avg(z))/sum(y)

I need to change the formula to a set analysis something like -

sum({<date={"<$(Max2)>$( Max1)"}>}+ avg({<date={"<$(Max2)>$( Max1)"}>}/

sum({<date={"<$(Max2)>$( Max1)"}>}

I managed to do it with the "replace()" func  -

replace(String,'sum(','sum({<date={"<$(Max2)>$(Max1)"}>}')

But I need some kind of “replaceif” condition that will check if the string is  ‘sum(‘ or ‘avg(’

if((string='sum(', 

     replace(string,'sum(','sum({<date={"<$(Max2)>$(Max1)"}>}'),
if((string)='Avg(',
          
replace(string,'Avg(','Avg({<date={"<$(Max2)>$(Max1)"}>}'),

any ideas?

THX

J

11 Replies
Jason_Michaelides
Partner - Master II
Partner - Master II

I've given an example in my previous reply.

Anonymous
Not applicable
Author

Sorry i didn't see

Thanks a lot it worked perfect