LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recursive Multiplication based on row and column values

Solved!
Go to solution

Greetings all, 


I have a 2d array of strings with values one colum representing an item set or subset number and the other being quantity of item in its parent looking like:
1                  2

1.1              3

1.1.1           5

1.1.2          4

1.2             4

1.11           2

2                1

I would like to produce a third colum that shows the total number of items overall (ie 2 of item 1 means 6 of item 1.1, 30 of 1.1.1, 24 of 1.1.2, 8 of 1.2, 4 of 1.11 and 1 of 2) Looking like:

 

1                  2             2

1.1              3             6

1.1.1          5             30

1.1.2          4             24

1.2             4             8

1.11           2             4

2                1             1

I was curious as to if anyone had a suggestion as to best handle the telling LabVIEW how and what to multiply. I imagen a something clever can be done with for and wile loops, but I'm not seeing it.

0 Kudos
Message 1 of 12
(5,909 Views)

So is this like a structured BOM with multiple sub assemblies?  I'm just trying to understand your calculations.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 12
(5,904 Views)

Yes, that  is exactily what it is. 🙂

0 Kudos
Message 3 of 12
(5,897 Views)

It is not clear how you calculate the third column from the first and second column. Where are the item values defined?

 

If you can operate on one line at a time, autoindex on a FOR loop to get one row/iteration. Use "spreadsheet string to array with a 1D integer array type and a period as delimiter to get an array of the integers contained in the first element. Apply your math using this array and the scanned second element. Are the values in the first element indices into a lookup table?

Now format the result back into a string and append to the 1D array from the autoindexing tunnel. Autoindex to get a 2D array containing three columns at the output tunnel.

0 Kudos
Message 4 of 12
(5,891 Views)

There are n0 counts of Assembly 1 
Assembly 1 contains n1 counts of assembly 1.1 and n2 counts of 1.2

Assembly 1.1 contains n3 counts of assembly 1.1.1

Assembly 1 value = n0

Assembly 1.1 value = n1*n0

Assembly 1.1.1 value = n3*n1*n0

Assembly 1.2 value = n2*n0

 

and so forth

0 Kudos
Message 5 of 12
(5,881 Views)
Solution
Accepted by topic author JScherer

I think you are looking for something like this.  I used the Match Regular Expression to find the last period nad then used that name to search in the variant for an attribute with that name.  It it exists, then the total count that is stored in the variant is returned.  Multiply and store in the variant.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 12
(5,873 Views)

Still pure gibberish to me. Where are the n# defined? E.g. where is n3 coming from in the third line of your example?

0 Kudos
Message 7 of 12
(5,869 Views)

@altenbach wrote:

Still pure gibberish to me. Where are the n# defined? E.g. where is n3 coming from in the third line of your example?


The way I understand the problem, 1.1 has 5 of 1.1.1.  Since we need 3 of 1.1, we need a total of 5*3=15 of 1.1.1.  Since each 1.1 has 4 of 1.1.2, we need 4*3=12 of 1.1.2 for every 1.1.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 12
(5,862 Views)
I would use variant attributes to store the item values based on their index. The autoindex your list, look for the patents item value and store the next item value...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 12
(5,860 Views)

This is correct.

 

Also,

What are the two blocks at the top of your for loop? Where can I find them in LabVIEW?

0 Kudos
Message 10 of 12
(5,849 Views)