cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

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!

Answers (2)

Answers (2)

0 Kudos

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

former_member186338
Active Contributor

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

0 Kudos

Hi Vadim,

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

Thanks

Bam

former_member186338
Active Contributor
0 Kudos

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.