Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Identify matching values in script based on certain criteria

Hi everybody,

I am currently trying to find out a way to identify matching entries based on certain criteria. This operation needs to be performed in the script.

Please see the example below:

   

BELNRAUGBLSHKZGDMBTRDMBTR.absoluteBLDATBUDATZFBDTAUGDTidentify
00020283250061226790S-981.532981.53218.05.201518.05.201518.05.201519.05.2015
00020413100061710887S-684.226684.22616.07.201516.07.201516.07.201520.07.2015
00020225920060969774S-676.725676.72516.04.201516.04.201516.04.201520.04.2015
00020481500061971806S-509.940509.94017.08.201517.08.201517.08.201524.08.2015
00020546860062167773S-509.873509.87316.09.201516.09.201516.09.201517.09.2015
00090010100062542784S-499.600499.60017.09.201517.09.201517.09.201530.10.2015x
00090010102002628310H499.600499.60017.09.201517.09.201517.09.201517.09.2015x
00020100160060441499S-487.373487.37316.02.201516.02.201516.02.201523.02.2015
00020214620061322831S-450.264450.26413.04.201513.04.201513.04.201501.06.2015
00130024680062972555S-386.349386.34922.12.201523.12.201522.12.201523.12.2015
00020609870062671631S-382.279382.27916.10.201516.10.201516.10.201517.11.2015
00020708650060118587S-375.106375.10601.12.201501.12.201501.12.201514.01.2016
00020203020061322908S-357.500357.50007.04.201507.04.201507.04.201501.06.2015
00020673790062749049S-356.369356.36916.11.201516.11.201516.11.201526.11.2015
00020159930060692060S-353.232353.23216.03.201516.03.201516.03.201519.03.2015
00090002562002448049H273.182273.18201.02.201501.02.201501.02.201502.02.2015x
00130023970060056626S-273.182273.18202.01.201405.01.201502.01.201408.01.2015x
000900006660056626H272.564272.56401.01.201501.01.201501.01.201508.01.2015

The yellow highlighted entries are the matching entries I want to identify. The match is based on the fields DMBTR.absolute and SHKZ. The rule is: Find entries that have identical DMBTR.absolute and the previous entry needs to be a "S" if I am a "H" vs. the previous entry needs to be a "H" if I am a "S". Both entries should be market in a newly created field (identify) with an "x".

Thanks a lot for your help!

11 Replies
tamilarasu
Champion
Champion

Felipe,

Just for fun . Below link can help you if you really want to change your name.

How to Change First Name & Last Name in the Account

Have a good day too

Cheers

tamilarasu
Champion
Champion

Hi Kiran,

Since the flag has to be set for both the values I have sorted the data twice. We don't have any function like below() in script level in order to create flag.

In the first load, I have created a TempIdentity flag by sorting the DMBTR.absolute and SHKZG fields in ascending order.

If( (SHKZG = 'S' and Peek('SHKZG') ='H') And (DMBTR.absolute = Peek('DMBTR.absolute')), 'x') as Tempidentity
Resident Data
Order by DMBTR.absolute, SHKZG;

In the next step, I have created the identity flag by sorting the data SHKZG field in descending order. but I want to keep the previously created x in the final result. So finally to get the desired output I have created the identity field which uses the previously created field (Tempidentity)

Result:
Load *,
If( (SHKZG = 'H' and Peek('SHKZG') ='S') And (DMBTR.absolute = Peek('DMBTR.absolute')), 'x', Tempidentity) as identity
Resident IdentityTemp
Order by DMBTR.absolute, SHKZG desc;

  DROP Field Tempidentity;

DROP Table Data, IdentityTemp


As we are taking the resident load, all the fields will be available in the resulting table. Since we don't need Tempidentity field anymore, we are dropping it.


Hope this helps you.