Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add a column in a table from the script

Hello,

I have 2 tables which i read from SAP: EKKO and EKPO.

EKKO contains the headers of the orders and EKPO contains all the lines in the orders.

Here is the thing, i want to add a column in EKKO depending on the value of a column in EKPO.

There is my EKKO table:

OrderDate
118.11.2015
219.11.2015
320.11.2015

There is my EKPO table:

OrderStatusQuantity
1X1
12
2X3
2X4
2X5
3X6

And there is the EKKO table i'm looking for:

OrderDateStatus
118.11.2015
219.11.2015X
320.11.2015X

For the same Order,

    If Status = 'X' for each EKPO line

          Add a column Status in EKKO with the value 'X'

How can i do this please?

This is how i loop the EKPO table but i have no idea how to do the rest...

LET vNumRows=NoOfRows('EKPO');

FOR i=1 to $(vNumRows)

  LET vStatus=Peek('Status',$(i));

    //do the stuff

NEXT;

Thank you very much for your responses,

Best Regards,

Loïc

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached example.


talk is cheap, supply exceeds demand

View solution in original post

7 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Maybe like this:

EKKO:

LOAD * FROM EKKO;

EKPO:

LOAD * FROM EXPO;

JOIN(EKKO)

LOAD Order, FirstSortedValue(Status, -Quantity) as Status

Resident EKPO

GROUP BY Order;


talk is cheap, supply exceeds demand
Not applicable
Author

This could work for my little example but not for my whole table.

This is not what i want, you just sort EKPO by the Quantity and take the Status of the bigger to put in EKKO.

I have to watch the Status of every lines in EKPO and only if all the lines have Status 'X' for an Order, put 'X' in the column Status from EKKO.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

EKKO:

LOAD * FROM EKKO;

EKPO:

LOAD

     Order,

     If(len(trim(Status))=0;'N/A',Status) as Status

FROM EXPO;

JOIN(EKPO)

LOAD Order, Count(distinct Status) as StatusCount

Resident EKPO

GROUP BY ORder;

JOIN(EKKO)

LOAD distinct Order, Status

Resident EKPO

WHERE StatusCount = 1 and Status = 'X';


talk is cheap, supply exceeds demand
Not applicable
Author

JOIN(EKPO)

LOAD Order, Count(distinct Status) as StatusCount

JOIN(EKKO)

LOAD distinct Order, Status

Resident EKPO

WHERE StatusCount = 1 and Status = 'X';

I think you missed something there.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Yeah, you're right. Fixed now.


talk is cheap, supply exceeds demand
Not applicable
Author

Hmm yeah that's what i thought...

I got this error message:

"Invalid expression

JOIN(EKPO)

LOAD Order, Count(distinct Status) as StatusCount Resident EKPO"

I think you can't JOIN a table and LOAD from this same table.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached example.


talk is cheap, supply exceeds demand