# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
cancel
Showing results for
Did you mean:
Creator III

## Best Way to Breakout Balance Field Incrementally

I was just curious, as it comes up a lot, but is there an easier way to create a balance range than the script below? We also use an input box version where to enter the range you want, but then if we end up with too many calculated dimensions in a report using that input box, it really affects the performance of the report.  So, is there an easier function to take something like a balance and just say break it out in \$100 increments as a new field? Look forward to hearing how others tackle this.

IF(ACCT_BALANCE<=200,'<200',
IF(ACCT_BALANCE>=200 AND ACCT_BALANCE<=400,'200-400',
IF(ACCT_BALANCE>400 AND ACCT_BALANCE<=600,'400-600',
IF(ACCT_BALANCE>600 AND ACCT_BALANCE<=800,'600-800',
IF(ACCT_BALANCE>800 AND ACCT_BALANCE<=1000,'800-1000',
IF(ACCT_BALANCE>1000 AND ACCT_BALANCE<=1500,'1000-1500',
IF(ACCT_BALANCE>1500,'1500+'
))))))) AS BalanceRange

Labels (6)

• ### Ranges

1 Solution

Accepted Solutions

My code above, wont handle 1500+. Please check the below.

``````tab1:
Dual(Replace(Class(ACCT_BALANCE,100),'<= x <','-'),Class(ACCT_BALANCE,100))) as BalanceRange;
AutoGenerate 25;``````

8 Replies
Specialist III

Check the Class function.  You can use a replace statement to change the "<= x <" to just a dash.

With Class:

``````tab1:
Dual(Replace(Class(ACCT_BALANCE,100),'<= x <','-'),Class(ACCT_BALANCE,100)) as BalanceRange;
AutoGenerate 25;``````

If you have fixed interval for buckets then you can use class function. See below link for the same

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Condi...

If you want to create custom bucket interval then use below method

``````Data:
ACCT_BALANCE
100
150
210
350
430
550
630
750
810
990
1100
1302
1400
1600
1700 ];

Buckets:
From,To,Bucket
0,200,<200
200,400,200-400
401,600,400-600
601,800,600-800
801,1000,800-1000
1001,1500,1000-1500
1501,E99,>1500 ];

Left Join(Buckets)
IntervalMatch(ACCT_BALANCE)
Resident Buckets;``````

My code above, wont handle 1500+. Please check the below.

``````tab1:
Dual(Replace(Class(ACCT_BALANCE,100),'<= x <','-'),Class(ACCT_BALANCE,100))) as BalanceRange;
AutoGenerate 25;``````

Creator III
Author

This looks very interesting, never seen this function layout. I am going to try it out and get back to you. Thanks

Creator III
Author

@Saravanan_Desingh So I like this and it seems to be a great solution to my previous method. The only problem is that the set cap of 5000+ that I put in shows up for each record instead of grouping them when I add it as a selectable field. (See image).

All other records fall under the numeric ranges, but each one set as 5000+ shows individually.

Creator III
Author

I had to remove the 5000+ section because it broke them all out individually instead of into a 5000+ bucket. But, doing it this way yout WILL get the entire breakout by whichever breakout you set... for example increments of 100

Can you try this?

``````tab1: