Hi Everyone, I have a very simple question. I'm using a TI process to create a hierarchical dimension from an ODBC excel source. I want to create a new variable (to be used as a consolidation/roll-up) with an IF statement based on the values in the Country dimension being Germany or France. So if the value is Germany or France then the variable (region) value should say Germany or France. Any other value in the country element should state 'Other'. The syntax I'm using in the Region variable is as follows:
IF (Country @= 'Germany');
(Region @='Germany');
ELSEIF (Country @= 'France');
(Region @='France');
ELSE (Region @= 'Other');
ENDIF;
Sorry for the simplicity of the question and the syntax shown above, very new to TM1. All responses are appreciated. Thanks
Variable IF statement in a TI Process
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: Variable IF statement in a TI Process
IF (Condition1);
Statement1;
ELSIF (Conditon2);
Statement2;
ELSE;
Statement3;
ENDIF;
Statement1;
ELSIF (Conditon2);
Statement2;
ELSE;
Statement3;
ENDIF;
- Martin Ryan
- Site Admin
- Posts: 1988
- Joined: Sat May 10, 2008 9:08 am
- OLAP Product: TM1
- Version: 10.1
- Excel Version: 2010
- Location: Wellington, New Zealand
- Contact:
Re: Variable IF statement in a TI Process
'@=' is for comparing two variables, not for assigning values to variables. So the above should beJJ2 wrote: IF (Country @= 'Germany');
(Region @='Germany');
ELSEIF (Country @= 'France');
(Region @='France');
ELSE (Region @= 'Other');
ENDIF;
IF (Country @= 'Germany');
Region ='Germany';
ELSEIF (Country @= 'France');
Region ='France';
ELSE;
Region = 'Other';
ENDIF;
You could also do
if(country@='Germany' % country@='France');
region=country;
else;
region='Other';
endif;
Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Jodi Ryan Family Lawyer
- Alan Kirk
- Site Admin
- Posts: 6610
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: Variable IF statement in a TI Process
You're mixing up your comparison and assigment operators. You use @= if you want to compare one string variable to another, and see whether the two match. (You just use = to compare numeric values.) If you want to assign a value to another variable (whether string or numeric) you just use the = operator. So the code that you have above should actually be:JJ2 wrote:Hi Everyone, I have a very simple question. I'm using a TI process to create a hierarchical dimension from an ODBC excel source. I want to create a new variable (to be used as a consolidation/roll-up) with an IF statement based on the values in the Country dimension being Germany or France. So if the value is Germany or France then the variable (region) value should say Germany or France. Any other value in the country element should state 'Other'. The syntax I'm using in the Region variable is as follows:
IF (Country @= 'Germany');
(Region @='Germany');
ELSEIF (Country @= 'France');
(Region @='France');
ELSE (Region @= 'Other');
ENDIF;
Sorry for the simplicity of the question and the syntax shown above, very new to TM1. All responses are appreciated. Thanks
Code: Select all
IF (Country @= 'Germany');
Region ='Germany';
ELSEIF (Country @= 'France');
Region ='France';
ELSE
Region = 'Other';
ENDIF;
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Re: Variable IF statement in a TI Process
Thanks Martin! Your examples worked perfectly!
-
- MVP
- Posts: 195
- Joined: Wed Jul 22, 2009 10:35 pm
- OLAP Product: TM1
- Version: 9.5.2 FP3
- Excel Version: 2010
Re: Variable IF statement in a TI Process
Or:Martin Ryan wrote: You could also do
if(country@='Germany' % country@='France');
region=country;
else;
region='Other';
endif;
Martin
Code: Select all
region=if(country@='Germany' % country@='France', country, 'Other');