Skip to Content
0

How to sorting the data in for...next function

Dec 27, 2017 at 07:04 AM

58

avatar image
Former Member

Hi expert,

I use "For...Next" function in case of divested entity in logic script and identify 3 variables in script which is retrieved from entity property dimension. Set of data that is used in script came from Entity Dimension as table below:

and the below is script

I expect that script should be run each set of data separately but in fact script will be sorted each property first then run script so the data that I get, it will show as below:

You can find that Entity B is disposed in year 2017 in first table but when I check the result, it is work like disposed in year 2015 while Entity D should be disposed in year 2015 but it work like disposed in year 2017.

My question is:

1.) Can I use For...Next function in this case? If not, can I use any function, please recommend me, I will be appreciated too much.

2.) If yes in the first question, please correct me that should I revise script or add something else for making script work correctly

Thanks in advance for your help and Happy New Year everyone.

Bam

capture1.png (5.3 kB)
script.png (19.2 kB)
capture2.png (5.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Vadim Kalinin Dec 27, 2017 at 09:14 AM
0

Just performed simple test in UJKT with ENVIRONMENTSHELL copy:

ENTITY dimension:

Script:

*SELECT(%ENS%,[ID],ENTITY,[DISPOSAL]=Y)
*XDIM_MEMBERSET ENTITY=%ENS%
*SELECT(%TIDS%,[DATE_CHANGE],ENTITY,[DISPOSAL]=Y)
*SELECT(%YS%,[YEAR_CHANGE],ENTITY,[DISPOSAL]=Y)
*FOR %EN%=%ENS% AND %TID%=%TIDS% AND %Y%=%YS%
*XDIM_MEMBERSET ENTITY=%EN%
*XDIM_FILTER TIME = [TIME].properties("TIMEID") = "%TID%"
*XDIM_FILTER TIME = [TIME].properties("YEAR") = "%Y%"
*NEXT

UJKT result:

LGX:

*XDIM_MEMBERSET ENTITY=BR,CA,DE,FR
*XDIM_MEMBERSET ENTITY=BR
*XDIM_FILTER TIME = [TIME].properties("TIMEID") = "20140800"
*XDIM_FILTER TIME = [TIME].properties("YEAR") = "2014"
*XDIM_MEMBERSET ENTITY=CA
*XDIM_FILTER TIME = [TIME].properties("TIMEID") = "20151200"
*XDIM_FILTER TIME = [TIME].properties("YEAR") = "2015"
*XDIM_MEMBERSET ENTITY=DE
*XDIM_FILTER TIME = [TIME].properties("TIMEID") = "20161000"
*XDIM_FILTER TIME = [TIME].properties("YEAR") = "2016"
*XDIM_MEMBERSET ENTITY=FR
*XDIM_FILTER TIME = [TIME].properties("TIMEID") = "20171000"
*XDIM_FILTER TIME = [TIME].properties("YEAR") = "2017"

Looks correct!


disp.png (24.2 kB)
Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Dec 27, 2017 at 07:26 AM
0

Please provide a full script, and post it as a text, not as picture. I don't see definition of variables.

Also please explain the required calculation logic.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 01 at 05:03 AM
0

Happy New Year Vadim,

Thanks a lot for your answer...First I will try to revise my script as your suggestion and let you know about the result.

Bam

Show 2 Share
10 |10000 characters needed characters left characters exceeded

My sample script demonstrates a correct order of id’s and properties in for/next loop.

1
Former Member
Vadim Kalinin

Hi Vadim,

I tried to reorder select function as your comment and it works properly.

Thanks

Bam

0