Table Row to Variables Loop Start Example

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…

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

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,

Hi there,

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

Br,
Ivan

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.

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

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”?

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

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

if(a >= 0)
{
if(c){
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?

Hi Davis,

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

Br,
Ivan

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

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

adding 8

I got a pulse…

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

Very Nice,

My format is definitely the problem, thanks.

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

if(a >= 0) { if (c) { 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.

Hi ipazin,

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

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

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

A post was split to a new topic: Curved connections

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.