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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If with text check in set analysis

Hello,

I have such expression for chart.

$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',sum({1<REGION = {' & $(vRegSelect) & '}>} [' & $Field & '])', ',') & concat(right($Field&')',1)))

But I want to use another IF there: if variable vRegSelect = 'EMEAR' then sum everything without selection ("{1}") ELSE sum for region.

Above I have summing for specific region which is set to variable vRegSelect, but when I want to add such if like this:

$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',sum(if(' & $(vRegSelect) & '=EMEAR,{1},{1<REGION = {' & $(vRegSelect) & '}>})[' & $Field & '])', ',') & concat(right($Field&')',1)))

It doesn't work :-(.

Probably it's because those brackets near EMEAR, but I don't know how to use text in text

6 Replies
rbecher
MVP
MVP

Try this:

$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',sum(' & if('$(vRegSelect)'='EMEAR','{1}','{1<REGION = {' & $(vRegSelect) & '}>}') & ' [' & $Field & '])', ',') & concat(right($Field&')',1)))

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
tresesco
MVP
MVP

Try:

$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',sum(if(' & $(vRegSelect) & '='&chr(39)&EMEAR&chr(39)& ',{1},{1<REGION = {' & $(vRegSelect) & '}>})[' & $Field & '])', ',') & concat(right($Field&')',1)))

If this doesn't work, try to share your app with sample data.

Not applicable
Author

Not working .

I've attached example to work with.

Not applicable
Author

Also dosen't work.

Just shared :-). Lesson from another topic learned

rbecher
MVP
MVP

Well, field names are case sensitive (Region instead of REGION) and $-expansion doesn't work inside:

$(=concat('if($Field=' & chr(39) & $Field & chr(39) & ',sum(' & if(GetFieldSelections([RegName],',')='EMEAR','{1}','{1<Region = {' & $(vRegSelect) & '}>}') & ' [' & $Field & '])', ',') & concat(right($Field&')',1)))

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
Not applicable
Author

Thank you, that's it.

But in meanwhile I've created next series and now I'm hiding and showing correct expression according to Region selection .

PS. I don't know why I don't have buttons with "correct" answer. Maybe I forgot to check that this topic is a question.