I would like to write an expression that uses the database field name.

I would like to write an expression that uses the database field name.

Avatar image
Aug 12, 2013
Vicky Allott wrote
I currently have the following expressions:
IF([CSV_COL(2)] = "Product Type", [CSV_COL(3)], "");
IF([CSV_COL(2)] = "Marketing", [CSV_COL(3)], "");
IF([CSV_COL(2)] = "Barcode", [CSV_COL(3)], "");

However I have a further 1500 attributes to define this for. Is there any way of writing this as a general statement, ie:

IF([CSV_COL(2)] = *attribute_code*, [CSV_COL(3)], "");

Thanks in advance,
Ria
Reply
3 Answers
Avatar image
Aug 13, 2013
Ira Kobylianska agent wrote
Thank you for your reply.

We are not sure that we understand correctly what you want to do with provided expression, since it would assign 3 column for all values from .csv column 2. It would be easier to simply assign .csv column 3 to each attribute at Assign Attributes step.
In case you meant something else, please provide us with the file and more details about conditions for your expression, so we could check it for you and provide you with possible solution

Waiting to hear from you
Avatar image
Aug 13, 2013
Vicky Allott wrote
Hi Ira,

The csv is laid out with one attribute per line as follows:

ProductID - AttributeName - Attribute Value

066598 - Product Type - Laptop
066598 - Marketing - Really good Laptop
066598 - Barcode - 0123456789

I have the expression:
IF([CSV_COL(2)] = "Product Type", [CSV_COL(3)], "");

In the left hand table attached to the "Product Type" Attribute

IF([CSV_COL(2)] = "Marketing", [CSV_COL(3)], "");
Is attached to the Marketing attribute and so on.

When I run these expressions the new sheet it produces is as follows:

ProductID - Product Type - Marketing - Barcode
066598 - Laptop - -
066598 - - Really good laptop -
066598 - - - 0123456789

What I'm looking for is a line of code that I can copy and paste for every attribute.

ADDITIONAL:
Ideally it would be useful to combine them in a single row:

ProductID - Product Type - Marketing - Barcode
066598 - Laptop - Really good laptop - 0123456789

Thank you for you input.
Avatar image
Aug 14, 2013
Ira Kobylianska agent wrote
Thank you for your interest.

There is no way to use single code that would parse all your attributes automatically, but you can create case with all conditions and use the same expression for all attributes. For example:
CASE
WHEN [CSV_COL(2)] = "Product Type" THEN [CSV_COL(3)]
WHEN [CSV_COL(2)] = "Marketing" THEN [CSV_COL(3)]
ELSE ''
END;

Yes, it would be easier if you could convert your file to single row, in this case Store Manager would assign all Attributes to your database fields automatically.

Please let us know if you have more questions