Regroup all the values ​​that are less than 1

Discussions about tabulating data in the designer or in batch mode
Post Reply
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Regroup all the values ​​that are less than 1

Post by Adnane »

hello to all,

Is there any way to regroup all the values ​​that are less than 1 automatically ?

for exemple: I have in my output tables as following :

Nationalité:
frence =1
Germany=1
Americaine=1
Italian=10

I want to make this :

Nationalité:
Italian=10
Other=3

See attachement :
Regroup values(Table).rar
Regroup value table
(45.5 KiB) Downloaded 514 times
Last edited by Adnane on December 26th, 2012, 3:26 am, edited 1 time in total.
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Regroup all the values ​​that are less than 1%

Post by Gregory Martin »

This is possible, though it requires some programming. I've attached an example where you can see what I've done. Basically, I added Others as a value to the value set, at the end. And then in your table's PostCalc logic I go through all the cells of your table, and when there is only a value of 1, I change it to 0 and increment the Others category. And then I format the stub, specifying that I want to "Hide when All Cells in Row are Zero." This will give you your desired table. Here is the logic:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
    
if TABLE1(idx,0) = 1 then
        TABLE1(idx,
0) = 0;
        
inc(TABLE1(tblrow(TABLE1),0)); // increase the Others row
    endif;
enddo;
Attachments
regroup.zip
(4.07 KiB) Downloaded 432 times
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Regroup all the values ​​that are less than 1%

Post by Gregory Martin »

Also, to do this I had to add idx as a temporary numeric variable to the logic (in the PROC GLOBAL section). To do this, press Control+L while viewing your table and you will have access to your table logic so that you can add the variable to PROC GLOBAL.
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Re: Regroup all the values ​​that are less than 1%

Post by Adnane »

Perfect, great tools !!

thank you Mr Gregory.
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Re: Regroup all the values ​​that are less than 1

Post by Adnane »

Another small problem with the same function of regroup value,

I add another column in the same table, which represents the percent, then I notice that the function work well only with the

column of numbers but not with percent,

see the example
Attachments
regroup_2.rar
(8.9 KiB) Downloaded 492 times
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Regroup all the values ​​that are less than 1%

Post by Gregory Martin »

You can add percents to your table, but then you have to switch the values for both the counts and the percents columns, like this:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
    
if TABLE1(idx,0) = 1 then
        TABLE1(idx,
0) = 0;
        TABLE1(idx,
1) = 0;
        
inc(TABLE1(tblrow(TABLE1),0));
        
inc(TABLE1(tblrow(TABLE1),1));
    
endif;
enddo;
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Re: Regroup all the values ​​that are less than 1

Post by Adnane »

To understand more this function,

please could you rewrite me this function but this time for exemple to regroup all valeus that are less than 3 ?

I tried but I did not come to found,

thank you very much sir gregory.
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Regroup all the values ​​that are less than 1

Post by Gregory Martin »

I answered this over email, but for the sake of anyone else, here is how you would regroup values less than 3:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
    
if TABLE1(idx,0) < 3 then
    
inc(TABLE1(tblrow(TABLE1),0),TABLE1(idx,0));
    
inc(TABLE1(tblrow(TABLE1),1),TABLE1(idx,1));
    TABLE1(idx,
0) = 0;
    TABLE1(idx,
1) = 0;
    
endif;
enddo;
Post Reply