Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

How to convert dimension expression to load script expression ?

Hi All

I have field name = aging_ar

This field have number from 1 to 360

I like to create a new filed name = aging_ar_class

which is

1=1-30

2=31-60

3=61-90

In chart dimension expression below working fine :-  

=If(aging_ar >= 1 and aging_ar <= 30, Dual('1-30', 1),

If(aging_ar >= 31 and aging_ar <= 60, Dual('31-60', 2), Dual('>61', 3)))

I have try convert the above expression to below for load script expression  :-

If(aging_ar >= 1 and aging_ar <= 30, Dual('1-30', 1),

If(aging_ar >= 31 and aging_ar <= 60, Dual('31-60', 2), Dual('>61', 3))) as aging_ar_class,

it does not work , Hope some one can advise me.

 

Paul

1 Solution

Accepted Solutions
rahulpawarb
Specialist III
Specialist III

Hello Paul,

May be try below:

If(aging_ar >= 1 and aging_ar <= 30,

   '1-30',

   If(aging_ar >= 31 and aging_ar <= 60,

   '31-60',

   '>61')) AS aging_ar_class

Regards!

Rahul

View solution in original post

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Looks OK to me. What is it doing incorrectly?

The conditions may fail if the ages are computed and are not integers. Modify it to this:

If(aging_ar < 1, Dual('0', 0),

  If(aging_ar <= 30, Dual('1-30', 1),

  If(aging_ar <= 60, Dual('31-60', 2),

  Dual('>61', 3)))) as aging_ar_class,

to guarrantee a value in every row.

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

Hello Paul,

May be try below:

If(aging_ar >= 1 and aging_ar <= 30,

   '1-30',

   If(aging_ar >= 31 and aging_ar <= 60,

   '31-60',

   '>61')) AS aging_ar_class

Regards!

Rahul

paulyeo11
Master
Master
Author

Hi Rahul

Wow you are good. Thank you very much.

Paul Yeo

rahulpawarb
Specialist III
Specialist III

Cheers,

Rahul