Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

If statement - transform from Expression to Script

I got these 2 expressions. IS it possible to "move" them to script? Need to use these as Dimensions other than Expressions in my tables. Thank you.

  1. 1. Status New:

if(
(
sum({<[Rolling Account Year Three]={'Most Recent'},[New/Renewal]={'New'}>} [Written Premium])/1000 >0 and
sum({<[Rolling Account Year Three]={'First Prior'},[New/Renewal]={'New'}>} [Written Premium])/1000=0),'New')

  1. 2. Status:

if(
(
sum({<[Rolling Account Year Three]={'Most Recent'}>} [Written Premium])/1000 - sum({<[Rolling Account Year Three]={'First Prior'}>} [Written Premium])/1000)>0,'Growing',
if(
(
sum({<[Rolling Account Year Three]={'Most Recent'}>} [Written Premium])/1000 - sum({<[Rolling Account Year Three]={'First Prior'}>} [Written Premium])/1000)=00,'NM',
if(
sum({<[Rolling Account Year Three]={'Most Recent'}>} [Written Premium])=0,'Lost',
if(
(
sum({<[Rolling Account Year Three]={'Most Recent'}>} [Written Premium])/1000 - sum({<[Rolling Account Year Three]={'First Prior'}>} [Written Premium])/1000)<0,'Shrinking'))))

Tags (2)
1 Reply
jontydkpi
Not applicable

Re: If statement - transform from Expression to Script

What are the dimensions of the chart/table containing these expressions?


You could do something like this (add the chart dimensions for dim1, dim2 placeholders below)


LOAD

  dim1,

  dim2,

  if((sum({<[Rolling Account Year Three]={'Most Recent'}, [New/Renewal]={'New'}>} [Written Premium])/1000 >0

  And sum({<[Rolling Account Year Three]={'First Prior'},[New/Renewal]={'New'}>} [Written Premium])/1000=0),'New'

  ) as Expr1,

  ...expr2 here... as Expr2

Resident ...

GROUP By

  dim1,

  dim2

And do the same for the second expression.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein