how to find minimum value in a column using transformer?
Moderators: chulett, rschirm, roy
how to find minimum value in a column using transformer?
i am trying to find minimum value in a column using transformer.
my data is like this
marks
45
56
90
65
80
i applied below logic.i have taken 2 stage variables.
varmin -->i drag the marks column to this.
cmp -->Min(varmin,cmp)
but i am getting all zero's in output column.
can anyone please help me in this problem
thnx in advnce
my data is like this
marks
45
56
90
65
80
i applied below logic.i have taken 2 stage variables.
varmin -->i drag the marks column to this.
cmp -->Min(varmin,cmp)
but i am getting all zero's in output column.
can anyone please help me in this problem
thnx in advnce
jhansi
Re: how to find minnimun value in a column using transformer
Seems to be like interview question.
Sortit--> use three variables --> compare it.
Sortit--> use three variables --> compare it.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's not what the Min() function does. Check the documentation to find out what the Min() function does.
The solution is most easily wrought using a pair of stage variables that you use to compare the value with its value in the previous row, and update only if it is smaller.
It is not necessary to sort the data for Minimum.
However if you require the overall minimum and to process in parallel, you need to partition by this column (so that all instances of each value are on the same node as each other), then use a sort-merge Collector into a Head or Tail stage and use that to capture the overall minimum from the minima from each node.
Actually, if you sort your data (subject to the same partitioning consideration as above), you can simply take the first or last from the sorted set.
The solution is most easily wrought using a pair of stage variables that you use to compare the value with its value in the previous row, and update only if it is smaller.
It is not necessary to sort the data for Minimum.
However if you require the overall minimum and to process in parallel, you need to partition by this column (so that all instances of each value are on the same node as each other), then use a sort-merge Collector into a Head or Tail stage and use that to capture the overall minimum from the minima from each node.
Actually, if you sort your data (subject to the same partitioning consideration as above), you can simply take the first or last from the sorted set.
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.
Re: how to find minnimun value in a column using transformer
when i am using 3 stage variables.it is is giving output like this
0
45
56
65
65
logic:
i hav taken 3 stg variables.
i draged marks col in to 1st & 3rd vars.
in 2 nd var i write
if stg1<stg2 then stg1 else stg2
but i am expecting 45 as final value
0
45
56
65
65
logic:
i hav taken 3 stg variables.
i draged marks col in to 1st & 3rd vars.
in 2 nd var i write
if stg1<stg2 then stg1 else stg2
but i am expecting 45 as final value
jhansi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Initialize stage variable to a very large value.
As each row is processed compare the column to the stage variable.
If the value in the column is less than the value in the stage variable, replace the stage variable's value with that value.
Once the last row has been processed the stage variable (and the output column to which it is linked) will contain the smallest value.
However see earlier notes about parallel execution.
As each row is processed compare the column to the stage variable.
If the value in the column is less than the value in the stage variable, replace the stage variable's value with that value.
Once the last row has been processed the stage variable (and the output column to which it is linked) will contain the smallest value.
However see earlier notes about parallel execution.
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.
You haven't said how many output records you need nor what you want them to look like. If you need all input records output with the overall minimum value, that's an entirely different process than what we've been discussing.jhansi wrote:but it gives only one record as output.
As noted, need more clarity.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: