Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
vengadeshpalani
Creator
Creator

for loop to set variable from field value

hi all

I want to set variable by using For Loop based on Customer field from Source Table,

Source:

LOAD Customer,

            Product

FROM (ooxml, embedded labels, table is Sheet1);

for loop starting here for every customer

selectedcustomer:

LOAD Customer as selectedcustomer,

          Product

Resident Source Where Customer  = ' Dynamically Change Customer Variable';

ExcludeCustomer:

LOAD Customer as ExcludeCustomer,

          Product

Resident Source Where Customer <> 'Dynamically Change Customer Variable';


4 Replies
Anil_Babu_Samineni

you are taking Variable and same time you are joining to each table and excluding the same variable. I am not sure i followed you

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
effinty2112
Master
Master

Hi Vengadesh,

Instead of all that looping why not:

Mappingselected:

Mapping

LOAD

Autonumber(Customer & '|' & Product,'SelectedID'),

'Selected Customer'

FROM

Test.xlsx

(ooxml, embedded labels);

Cross:

Load

Distinct

Customer

FROM

Test.xlsx

(ooxml, embedded labels);

Outer Join(Cross)

Load

Distinct

Product

FROM

Test.xlsx

(ooxml, embedded labels);

Final:

Load

ApplyMap('Mappingselected',Autonumber(Customer & '|' & Product,'SelectedID'),'Excluded Customer') as Status,

*

Resident Cross;

Drop table Cross;

Product Customer C1C2C3C4
ASelected CustomerSelected CustomerSelected CustomerExcluded Customer
BSelected CustomerSelected CustomerSelected CustomerExcluded Customer
CSelected CustomerSelected CustomerExcluded CustomerExcluded Customer
DSelected CustomerSelected CustomerExcluded CustomerExcluded Customer
ESelected CustomerExcluded CustomerExcluded CustomerExcluded Customer
FSelected CustomerExcluded CustomerExcluded CustomerExcluded Customer
GSelected CustomerExcluded CustomerExcluded CustomerSelected Customer
HSelected CustomerExcluded CustomerExcluded CustomerSelected Customer
ISelected CustomerExcluded CustomerExcluded CustomerExcluded Customer
JExcluded CustomerSelected CustomerSelected CustomerExcluded Customer
KExcluded CustomerSelected CustomerExcluded CustomerSelected Customer
LExcluded CustomerExcluded CustomerExcluded CustomerSelected Customer
MExcluded CustomerExcluded CustomerExcluded CustomerSelected Customer
OExcluded CustomerExcluded CustomerSelected CustomerExcluded Customer
ZExcluded CustomerExcluded CustomerExcluded CustomerSelected Customer

Regards

Andrew

vengadeshpalani
Creator
Creator
Author

Ok Anil

I removed join

My question is i have field Customer by using customer i want to perform some action for every customer so i want to add for loop

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi vengadesh,

it's not clear what result you are expecting.

Instead of describing the solution (which you are obviously struggling with, hence posting on here), why don't you illustrate the output you are looking for.

Marcus

Community Browser