Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

My AppMap recode with condition not return correct value.

Hi All

I have below script with the help from Staffen and HIC which using loop to load multiple raw data , is work fine.

FOR i=0 TO NoOfRows('FileList_Sales') -1

LET vFile = PEEK('FileName_Sales', $(i), 'FileList_Sales');

For each vFileName in FileList('$(vRAWPath)*.txt')

if(subfield(subfield('$(vFileName)','\',-1),'.',1) = '$(vFile)') then

sales:

LOAD

  FileBaseName() as SOURCE,

  'SALES' as table,

  @50:60T as [date], 

  @10:38T as [COMPANY],

  @307:312T as [grouping],

  ApplyMap('MapGroup_SG',@307:312T) as [GROUP_CLASS_TDS],

  @121:133T as [cost]

FROM "$(vFileName)" (ansi, fix, no labels, header is 0, record is line); 

endif

Next vFileName

next i

My issue is when i using below script to recode grouping to GROUP_CLASS_3 Is not return correct value.

sales_G:

LOAD grouping,

   

    if (SOURCE='Q_DOD_2016',ApplyMap('MapGrouping_SG',grouping),

    if (SOURCE='Q_FCKL09',ApplyMap('MapGrouping_MY',grouping),

    )) as [GROUP_CLASS_3]

resident sales;

Hope you can advise me.

enclosed my QVW

Paul

16 Replies
avinashelite

Ok , let me explain

*First, all your conditions are fine

*You have created the sales_G table and liking the sales table via grouping

*grouping field doesn't have the unique key because of which it showing all the related files associated via

grouping

*What is did is in the new table sales_G I created the NEW_SOURCE so that will get the right combination

one more way to do this is

in the sales table create a key like

SOURCE&'-'&grouping as KEY

and create  similar key and an indicator like below  in sales_G table

SOURCE&'-'&grouping as KEY,

'sales_G ' as Indicator,


and use the  Indicator in set analysis to get the rite data ...




Hope you understand now.





paulyeo11
Master
Master
Author

Hi Avinash

Wow your understanding of data model is very well. In the first place how do know figure out that link issue ? I just want to learn from you how you do trouble shooting.

Does the way I do the recode it is call partial reload or resident load ?

Paul Yeo

DIrector

TDS Technology (S) P/L

Whatsapp +659:261804

avinashelite

It comes by experience

*First I checked how is the data

*Then saw what the results your getting , you had both the values and then I checked the mapping key and got the issue from their

I suggest you to verify it step by step the is the best approach

if you have got the answer mark the correct answer and close this thread

paulyeo11
Master
Master
Author

Hi Sir

Sorry to trouble you again.

I just got internet , and i have check the result . I notice that the result is still wrong.

Kindly note that GROUP_CLASS1 return correct value , but GROUP_CLASS3 return wrong value.

As when grouping = 1 , for Q_DOD_2016 should be recode to G1-SG

As when grouping = 1 , for Q_FCKL09 should be recode to G1-MY

Kindly take a look at the enclosed QVW. Refer to Table 1. I am using the QVW you send me.

Thank you for your help.

Paul

avinashelite

check this one

paulyeo11
Master
Master
Author

Hi Avinash

I saw you create a key to link the 2 table. Thank you very much finally now working fine , i can sleep well .

Paul

avinashelite

Aha nice ..have a good sleep