# Cognos Data Manager Variables in Job Stream

In this article we are explaining how to use variables inside a Job Stream. Through this article you are able to learn about the role of a variable inside Job Stream. Before start we are assuming that, you are aware about the basics of Cognos Data Manager (If not you can refer this article.).

Variables (Refer this article to learn about variables in Cognos Data Manager.) in a Job Stream is not directly used. But it is a place where you can define variables to use them inside the child components of Job Stream.

For example you can define a variable let say week and then you can use the same inside
• Conditional node to handle week logic such as latest week, last week of month and so on.
• Procedure node to create dynamic query for a particular week.
• Child Job Streams.
• Child Builds (Fact and Dimension) to load weekly data.

Ok enough theory let's start with create our first variable inside our Job Stream. (How to create a Job Stream ?)

Steps to create a variable in a Job Stream
1. Create Job Stream if not exists. (How to...)
2. Select the Job Stream. Right click and select Properties.
3. In properties select variable tab. In this tab we perform following option.
• Edit existing variable.
• Delete variable if not required.
• Move Up/Move Down*: Re-Arrange variables. Sequencing of variable is important in case of dependent variables.
4. Click on Add button to add a new variable.When you click on Add button a new window is opened. In this window we can define following property of a variable
• Name: Variable name.
• Type: Variable type. List of available types
• Precision and Scale**: It is applicable only for selected data type.
• Expression***: Used for calculated variables.
5. Click OK to save and Close the variable property window.
6. Click OK to save and Close the Job Stream property.
* Move Up/Move Down: It is used to re-arrange variables. Variables sequencing is important in case of dependent variables. For example lets take following example of 3 integer variables are define in the below order
\$x:=\$y+1;
\$z:=\$x*15;
\$y:=1867;
When you try to execute the Job Stream it is failed. Why? Yes you are thinking correctly. It is because of variables sequence, but why. As given in above example. Variable x using y, so what's the problem? The answer is very simple if var1 using var2, then var2 must define (declare) before var1. To run the Job Stream correctly you have to define variables in following order.
\$y:=1867;
\$x:=\$y+1;
\$z:=\$x*15;
** Precision and Scale: We will explain you later.
***Expressions: It is used for complex calculation. for example in a variable you want a value which is multiple of 19 of another variable use below calculation.
\$x:=7869
\$y:=19*\$x;

Next Recommended Article: