cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Condition in Transformation file/Conversion file

Former Member
0 Likes
655

Hi People,

Below snapshot is my Csv file and I want to get X value for TID (BPC Property) if TID length is 3 in csv file?and rest should be as Empty?

So in this case 504, 505 value should be update as X in BPC for TID Property and others FZ,ZK, A etc should be as Empty.

Could you please let me know how i can do this?


Csv File:

Transformation file.

Thanks,

Vishu

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

Hi Vishu,

You can use conversion file for TID with JavaScript like:

*        js:%external%.toString().length==3 ? "X" : ""

Vadim

Former Member
0 Likes

Hi Vadim,

Hope you are well!

I have used Javascript in Conversion file.

Converted TID data to X if TID value length is 3 and rest of records are rejected.

See below snapshot

Even i tried to add two lines instead of using JavaScript. This solution also converting to X if TID value length is three and rest it is loading as it is.

Output data

Could you please correct me if i am missing anything. thanks!

Vishu

former_member186338
Active Contributor
0 Likes

Yes, you are right! Just checked....

It's not possible to generate empty value in the property using conversion file!

You can generate empty property in transformation file, but you can't check string length in transformation - only direct string comparison...

May be instead of empty property you can use "N" like:

*    js:%external%.toString().length==3 ? "X" : "N"

Vadim

former_member186338
Active Contributor
0 Likes

P.S. You can also create some multi step process:

1. Import with js:%external%.toString().length==3 ? "X" : "N"

2. Export the dimension to some fixed text file.

3. Import again with different transformation and without conversion:

MAPPING

...

TID=*if(TID = *str(N) then *str(); *str(Y))

...

Former Member
0 Likes

Oh okay I understood.

Thanks Vadim for your time and help.

- Vishu

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Likes

Or without JavaScript - 2 lines:

???      X

*  

Vadim