How to use Power (Pwr) function
Moderators: chulett, rschirm, roy
How to use Power (Pwr) function
Hi All,
I am trying to use power function (pwr)in stage variable.. However, I am unable to achieve my result set in my parallel job.
Below is the expression that I need to use in my derivation. Just for your information, below derivation works properly fine when I run the formula in Excel sheet with some values:
((1+DSLink.Percent/100)^(DSLink.Period/12) -1)
I tried using below derivation in stage variable but was unsuccessful and it is not giving me correct results:
pwr((1+DSLink.Percent/100),(DSLink.Period/12)) -1
To be specific, I want the below expression to be calculated:
((1+(-2)/100)^(1/12)-1)*100
Can someone please help me out.
Thanks!
I am trying to use power function (pwr)in stage variable.. However, I am unable to achieve my result set in my parallel job.
Below is the expression that I need to use in my derivation. Just for your information, below derivation works properly fine when I run the formula in Excel sheet with some values:
((1+DSLink.Percent/100)^(DSLink.Period/12) -1)
I tried using below derivation in stage variable but was unsuccessful and it is not giving me correct results:
pwr((1+DSLink.Percent/100),(DSLink.Period/12)) -1
To be specific, I want the below expression to be calculated:
((1+(-2)/100)^(1/12)-1)*100
Can someone please help me out.
Thanks!
Vaibhav
-
- Premium Member
- Posts: 425
- Joined: Sat Nov 19, 2005 9:26 am
- Location: New York City
- Contact:
....my two cents
-Check the data type, the function expect dfloats
-Check the order of precedence in the math operations imposed by the parentheses...as per your example is a bit off
- Hardcode a couple of sample to.check that the function works as expected
Good luck
-Check the data type, the function expect dfloats
-Check the order of precedence in the math operations imposed by the parentheses...as per your example is a bit off
- Hardcode a couple of sample to.check that the function works as expected
Good luck
Julio Rodriguez
ETL Developer by choice
"Sure we have lots of reasons for being rude - But no excuses
ETL Developer by choice
"Sure we have lots of reasons for being rude - But no excuses
Hi Rodriguez,
I verified the datatypes and they are correctly set. Similarly, the parenthesis imposed are correct.
Hi UCDI,
If I consider the hard coded example as ((1+(-2)/100)^(1/12)-1), expected result is -0.001682143.
However, in DS, when I use the PWR function, I am always getting value as 1 (be it any hard coded combination). Maybe in my case, PWR function is not working well when considering fractional values.
To keep my work going, I implemented the work around. I calculated both the fractional values in separate stage variables i.e.
sv1: (-2)/100
sv2: (1/12)
sv3: (pwr(1+sv1,sv2)-1)
If I am using the above way, I am getting my correct results.
Thanks!
I verified the datatypes and they are correctly set. Similarly, the parenthesis imposed are correct.
Hi UCDI,
If I consider the hard coded example as ((1+(-2)/100)^(1/12)-1), expected result is -0.001682143.
However, in DS, when I use the PWR function, I am always getting value as 1 (be it any hard coded combination). Maybe in my case, PWR function is not working well when considering fractional values.
To keep my work going, I implemented the work around. I calculated both the fractional values in separate stage variables i.e.
sv1: (-2)/100
sv2: (1/12)
sv3: (pwr(1+sv1,sv2)-1)
If I am using the above way, I am getting my correct results.
Thanks!
Vaibhav
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
How do you define the data type of a constant in an expression, vgupta88? This is a technique with which I am not familiar, despite almost 50 years of working with computers! But I'm always happy to learn.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: