Sunday, April 6, 2014

How to get ratio of two numbers through informatica?

 


What will be the logic?
e.g:--
id Number1 Number2  Ratio
1   3000    488     15:7 
2   200     100      2:1
3    40      15      8:3

Use dis code in java expression to get GCD.
Number1=Number1;
Number2=Number2;
int i,j,GCD_temp=1;
i=Number1;
j=Number2;
while(i!=0 && j!=0)
{
 if(i>j)
 {
 i=i-j;
 }
 else
 {
 j=j-i;
 }
}
 if(i==0)
 GCD_temp=j;
 else
 GCD_temp=i;
GCD=GCD_temp;  \


Your expression ports will be:
1 Product_ID as "Product_ID"
2 Year1 as "Year1"
3 Sales1 as "Number1"
4 Year2 as "Year2"
5 Sales2 as "Number2"
6 GCD
7 RatioName as "TO_CHAR(Year1, 'YYYY') || '_' || TO_CHAR(Year2, 'YY')"
8 Ratio as "TO_CHAR(Number1 /GCD|| ':' || TO_CHAR(Number2 / GCD)"
 

No comments:

Post a Comment