Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

silambarasan130
Contributor II

Explain how it’s works..

Could Anyone pls explain me below expression..

         Replace(Replace(Replace(Replace(Class(GrossEarnings,10000),'<=',''),'x',''),'<','-'),' ','')

1 Solution

Accepted Solutions
Not applicable

Re: Explain how it’s works..

Class function will split [GrossEarnings] into buckets of 10,000 giving them names like 0 <= x < 10000

The Replaces changes this formatting to 0-10000 by replacing <= and x with nothing and < with -

You could also use: REPLACE(CLASS(GrossEarnings, 10000),'<= x <','-')

5 Replies
Not applicable

Re: Explain how it’s works..

Class function will split [GrossEarnings] into buckets of 10,000 giving them names like 0 <= x < 10000

The Replaces changes this formatting to 0-10000 by replacing <= and x with nothing and < with -

You could also use: REPLACE(CLASS(GrossEarnings, 10000),'<= x <','-')

phaneendra_kunc
Valued Contributor III

Re: Explain how it’s works..

Class function will give result out put in this format 0 <= x < 10000

above expression is replacing all characters between 0 and 10000 with a dash "-"

you can use this to make it little easy

Replace(Class(GrossEarnings,10000),' <= x < ','-')

But still i htink you can improve more as above will give you output like below.

0-10000

10000-20000

20000-30000

....

....

If you see you dont know 10000 is included in first set or second set, so try using below

=subfield(Class(GrossEarnings,10000),' <= x < ',1)&'-'&subfield(Class(GrossEarnings,10000),' <= x < ',2)-1

this will give you output like this

0-9999

10000-19999

20000-29999

silambarasan130
Contributor II

Re: Explain how it’s works..

Thank you so much..

silambarasan130
Contributor II

Re: Explain how it’s works..

Thank you so much..

MVP
MVP

Re: Explain how it’s works..

Rather use the much simpler:

     Num(Class(GrossEarnings,10000))

Community Browser