Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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,
You seem to have forgotten to post your code!
for rename field (field, not values) you can search Rename Field in the online help
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]);
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
Try like this.
Good approach although the second expression should be all <>"I".
But what if a combination of fields is true/false (='I' or <>"I")..?
Thanks Ralf. Can you clarify why the second expression should be <> 'I' rather than = 'I'
..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]
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])