14 Replies Latest reply: Oct 19, 2016 7:18 AM by Karunpreet Soni

Logical Error

Hello Everyone,

I am facing an issue while creating a logic. Require your help

Data:

 A 1 2 2 2 2 3 3 3 3 4 2 2 3 3 4 4

Output:

 A Output 1 1 2 2_1 2 2_2 2 2_3 2 2_4 3 3_2_4_1 3 3_2_4_2 3 3_2_4_3 3 3_2_4_4 4 4_3_2_4_4_1 2 2_5 2 2_6 3 3_2_6_1 3 3_2_6_2 4 4_3_2_6_2_1 4 4_3_2_6_2_2

The logic behind the output is very easy.

Thanking you all in anticipation

Regards

KP

• Re: Logical Error

Hi,

If you explain the logic behind the output (that you say it's easy), it would be easier to help. I couldn't find the pattern.

Eduardo

• Re: Logical Error

Hi ,

Can you explain the logic so people don't spend time guessing!

• Re: Logical Error

Hi,

The logic behind the output is very easy.

BUT YOU NEED TO TELL US WHAT IT IS!

Crystal ball is not working today!

Andy

• Re: Logical Error

Sorry Guys (@awhitfield, @vinieme12, @eduardo.sommer ) for that lame line; 'Logic behind it is very easy'.

Please see the below image, it is very informative and explains the logic .

The Order of input data will not change. This data would come from SAP

• Re: Logical Error

This Tree diagram is not informative nor is it explaining the derivation of the node elements!

Can you explain how each item is evaluated?

for example:  4_3_2_4_4_1  and 4_3_2_6_2_2 ??

• Re: Logical Error

See attached and let me know if this helps

• Re: Logical Error

actually i was able to achieve the same ouput with a similar type of code but the problem here is its not a dynamic code, what if someday 5 is also added to the tree

• Re: Logical Error

won't be a problem, try and let me know

• Re: Logical Error

Hi,

Temp:
LOAD A,Autonumber(RowNo(),A) As NR,AutoNumber(A) as Level,RowNo() As Rowno
Inline [
A
1
2
2
2
2
3
3
3
3
4
2
2
3
3
4
4
]
;

Load Rowno,A,If(Level > 2,NewA&AutoNumber(RowNo(),NewA),NewA) as NewA;
If(Level = 1,A,
If(Level = 2,A&'_'&NR,
If(Peek(A) <> A,A&'_'&Peek(NewA)&'_',Left(Peek(NewA),Len(Peek(NewA))-1)))) as NewA
Resident Temp;
Drop Table Temp;

Regards,

Antonio

• Re: Logical Error

Nice ; but I'd generally avoid Preceding load

• Re: Logical Error

Hey antoniotiman thanks for your instant reply, but as I told vineet the problem here is its a static code. What if 5,6,7 are added to the tree then this will work only for 1,2,3 and 4