Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
catalyst_75
Contributor II
Contributor II

If..Then.. Renaming fields based off data

I have done some searching and found many post about standard if/then and nested statements. What I could find and was wondering is if I could alias a field based on a different field.

Here is some code that I attempted in the script editor. I know its not right, but I think it get the point and idea of what I am trying to do across.

Is something like this possible? If not, something close? Or do I need to load the data differently to accomplish what I am trying to do?

Thanks,

9 Replies
Not applicable

You seem to have forgotten to post your code!

maxgro
MVP
MVP

for rename field (field, not values) you can search Rename Field in the online help

catalyst_75
Contributor II
Contributor II
Author

Sorry, could have sworn it was there before hitting post. lol

I had something like this:

If(pat_carrier_type = 'I', pat_carrier_id AS [Conact ID], pat_carrier_id AS [Company ID]);

If(pat_payor_type = 'I', pat_payor_id AS [Conact ID], pat_payor_id AS [Company ID]);

If(pat_tpa_type = 'I', pat_tpa_id AS [Conact ID], pat_tpa_id AS [Company ID]);

rbecher
MVP
MVP

Hi Cory,

this will not work. But what would work if you use a variable for the alias or, do a concatenate load where you have different fields depending on the selected data set:

Result:

LOAD

pat_carrier_id AS [Conact ID],

...

From ...

Where pat_carrier_type = 'I';

Concatenate LOAD

pat_carrier_id AS [Company ID],

..

From ...

Where pat_carrier_type <> 'I';

But think this needs to be a litle bit more elaborated..

- Ralf

Astrato.io Head of R&D
Not applicable

Try like this.

example.PNG.png

rbecher
MVP
MVP

Good approach although the second expression should be all <>"I".

But what if a combination of fields is true/false (='I' or <>"I")..?

Astrato.io Head of R&D
Not applicable

Thanks Ralf. Can you clarify why the second expression should be <> 'I' rather than = 'I'

rbecher
MVP
MVP

..for the else parts:

if(pat_carrier_type = 'I', pat_carrier_id,

  if(pat_payor_type = 'I', pat_payor_id

    if(pat_tpa_type = 'I', pat_tpa_id)))

AS [Conact ID],

if(pat_carrier_type <> 'I', pat_carrier_id,

  if(pat_payor_type <> 'I', pat_payor_id

    if(pat_tpa_type <> 'I', pat_tpa_id)))

AS [Company ID]

Astrato.io Head of R&D
Not applicable

For nested if you should try this once

if(pat_carrier_type = 'I',pat_carrier_id,If(pat_payor_type = 'I',pat_payor_id,If(pat_tpa_type = 'I',pat_tpa_id))) AS [Company ID])