Table Row to Variables Loop Start Example

#1

Hi Ipazin,

I am down to another challenge that is popping out at me with Parameters.
I have a Form that produces a Orders Table.

I want to have the Orders Table provide the parameters using the Table Row to Variables Loop Start and Loop End.

The form will collect variables that will perform calculations to produce a Dataset. Each Row in the Table is to be a Parameter of 7 or more variables.
How does one set that up? I am looking at a example below that appears to have 1 parameter, but I need about 15.

knime://LOCAL/Example%20Workflows/workflow_SQL-group/12_Using_TableRows_as_FlowVariables_in_Loop

Davis

0 Likes

Data Collection
#2

Hi Davis,

I moved your question to new topic as it seems to me it is not so much related to the previous matters discussed.

The example you are looking only has one parameter (1 flow variable for each row) because there is only one column in Table Creator node. If you have multiple columns you will have multiple parameters in each iteration which can then perform calculations to produce a desired data set.

Hope this helps.

Br,
Ivan

1 Like

#3

Hi Ipazin,

I am challenged with

Table Row To Variable Loop Start

I want each Row in a table to supply numerous parameters downstream.

Am I on the proper path?

Do you have a simple example that specifically caters to

multiple parameters coming from a Row,

-A report is produced from the results of the parameters used in a formula from the 1st row.

-Next row of parameters processed.

-Another report generated.

Loop thru Rows 1 & 2

ex. columns A - D

Row 1 Values 1, 2, 3, 4

Row 2 Values 5, 6, 7, 8

Formula (A+B)/(C*D)

Report for 1st Loop = 3/12 = .25

Report for 2nd Loop = 11/56 = .196

If more Orders are added to the Table, they will be processed and the finished processed rows will be skipped.

Do you have an example of this type of process in the archives you can share?

Thanks for any suggestions…

0 Likes

#4

Hi Davis,

seems you are on a good path.

Here is example with your data:
2019_06_11_Table Row To Variable Lop Start _Example.knwf (18.1 KB)

Inside loop you can send result using Send Email node or save it as a PDF/CSV on you file system depending on your use case…

Br,
Ivan

0 Likes

#5

Hi Ipazin,

I am probably 90% complete with the effort and I am having a road block with the Column

Expression Node.

This is what I am trying to calculate…

a=column(“pro_Arg1”)

b=column(“pro_Arg2”)

c=column(“pro_Arg3”)

v=column(“Dimensions”)

q=column(“QTY”)

if(isMissing©)

q=((a)+((b)*(v)))

if (a > 0)

q=((a)+((b)*(v))+((v)/©))

x=((v)/©)

h=((b)*(v))

QTY

QTY is what I am trying to evaluate.

I get results like 1.033.6555 ???

As if it is concatenating the data instead of adding the data.

The Function to Add, Subtract etc. appears to be in the wrong format. When I look at your example

you have

($${IA}$$+$${IB}$$)/($${IC}$$*$${ID}$$) and it works…

But this gives me an error with the Column Expression Node. Any suggestions?

Regards,

0 Likes

#6

Hi there,

I guess it is concatenating because those variables/columns are String type :wink:

Br,
Ivan

0 Likes

#8

After updating with integer instead of string (Thank You), I am still having a challenge with a (If Condition).

Currently, I have…

a=column("pro_Arg1")
b=column("pro_Arg2")
c=column("pro_Arg3")
v=column("Value")
q=column("QTY")

if(isMissing(c))
q = (a)+((b)*(v))

if (a > 0)
q = (a)+((b)*(v)+(v/c))
round(toDouble(q),2)

q

But this is not giving me good results. I am certain my format is wrong. What if “c” is missing and
a > 0? I think this is where it is bombing out to give me 0 instead of a value.
" Please advise.

0 Likes

#9

Hi there Davis,

Can you explain your logic? If this is how you code looks like seems to me the If needs a bit different syntax.

I have edited your post so that code is more readable (Preformatted text option) :wink:

Br,
Ivan

0 Likes

#10

Hey ipazin,

Yes, I can explain the logic.
Here we are creating variables from the dataset and I am naming them a,b,c, v, and q.

If variable c is missing or “0” or blank I use the equation q = (a)+((b)(v))
else
I use the equation q = (a)+((b)
(v)+(v/c))
as long as a > 0.

As I type this response, I am thinking that instead of having If (a > 0)
I can replace this with else.
If a = 0, that would not hurt the equation at all. In the above missing c, I was avoiding a division by 0.

P.S. How are you executing the “Preformatted text option”?

0 Likes

#11

Hi Davis,

Here is option for Preformatted text when writing on Forum:

PreformText

Using this your code should stay intact and thus readable :wink:

Anyways here is how you can write your logic in Column Expressions node:

if(a >= 0)
    {
    if(c){
            q = a + b*v + v/c;
         }  
    else{
            q = a + b*v;
        }
    }
else{
    q = a;
    }

What remains is to determine what to do in case a is less than zero. Code If(c) will return true if value is any number different than zero :wink:

Br,
Ivan

0 Likes

#12

Awesome Structure,
It makes sense. My results are being tested with the following…

if(a >= 0)
{
if©{
q = a + bv + v/c;
}
else{
q = a + b
v;
}
}
else{
q = a + 2; //Here I changed it from q = a; to q = a + 2;
}

q

I believe q should equal to 2, not 0. What do you think?

0 Likes

#13

Hi Davis,

I just set q = a as an example. You set q depending on your logic :wink:

Br,
Ivan

0 Likes

#14

I do understand, and that is perfect. I am testing the formula by saying that if a = 0, adding 2 to the equation, should result in a value of 2, and 0 if we add nothing.
5 if we add the value of 5 and 0 if we add nothing etc.

However, The value is not adjusting to the different logic I am applying to the formula
q = a

0 Likes

#15

I tried this and got same results.
if(a >= 0) { if © { q = a + (bv) + v/c; } else{ q = a + (bv); } } else{ q = (a + 8); }

adding 8

0 Likes

#16

I got a pulse…

if(a >= 0) { if © { q = a + (bv) + v/c; } else{ q = a + (bv) + 8; } } else{ q = (a + 8); }

0 Likes

#17

Very Nice,

My format is definitely the problem, thanks.

0 Likes

#18

Trying to test this part of the equation is not yielding a result…

if(a >= 0) { if © { q = a + (b*v)}

I don’t appear to be getting true on this Test when “a” is less than zero…unless the result of 0 = True.

I thought 1 = True. I could be wrong. But it appears to be working if that is the case.

0 Likes

#19

Hi ipazin,

Is there a way to to represent NULL in the formula?

0 Likes

#20

Hi Davis,

to be honest not sure what is the status of your testing now :slight_smile:

I will try to explain logic. First if is for a values higher or equal to zero. So if a = o you will go there. Then it depends on c value. If c is different than missing and zero you will use first formula (q = a + b*v + v/c). Otherwise second (q = a + b*v). If a is smaller than zero you will have last formula calculated (q = a).

Hope it is a bit clearer now.

Br,
Ivan

0 Likes

#21

Morning ipazin,

Yes, I agree with the logic and it appears to be performing properly.

This part of the challenge I believe is complete.

Davis

1 Like