From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build a 3D table from a 2D table with conditions

Solved!
Go to solution

 

Hi all,

I've got a difficulty to build a 3D table.
Basically, I have a 2D table with many data and I need to build a 3D table where in each page I'll have all the rows combining the conditions (same year, same class). After the treatment will be done page by page on an other loop.

So far, I extract the first row of the table and then I check row by row the rest of the table. If a line is OK with the conditions I exclude it from the table and I concatenate it to all the other rows following the conditions in the inside loop. The shift register is supposed to actualize the table loop after loop. After the inside loop I add the row exclude at the beginning of the first loop to gather all the data following its condition. 
At the end, I index the data in order to build the 3D table.

 

The point is that it is not working at 100%. I can have pages with a couple of rows (ok) with many rows (still ok) but sometimes a row appears alone in its on page despite the fact that he should be in another page, with others rows.

 

Do you have an idea to enhance this?

 

Thanks,

 

Here, the loop with the 'True case':

Caracatos_0-1578923727481.png

 

False case:Caracatos_1-1578924053183.png

 

0 Kudos
Message 1 of 9
(2,492 Views)

@Caracatos wrote:

Do you have an idea to enhance this?


Please attach your code. Pictures are insufficient to debug and test.

Also make sure the input has typical default data. Then tell us what the desired output should be.

 

You are talking about a 3D array of strings. (A "table" in LabVIEW is always 2D).

 

Overall, you code seems way to convoluted (index array is resizeable, constant array resizing operations, prepending instead of appending, etc.)...

 

0 Kudos
Message 2 of 9
(2,453 Views)

It could be an array of table results.  That would be 3D.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 9
(2,429 Views)

@billko wrote:

It could be an array of table results.  That would be 3D.


Since a table is just a 2D array of string (data wise), You cannot create an array of tables (i.e. an array of arrays) unless you jump through some hoops (e.g. create a 1D array of clusters, each containing a table). 😉

0 Kudos
Message 4 of 9
(2,427 Views)

Consider using Conditional Tunnels:

Conditionally Writing Values to Loop Output Tunnels 

It will allow you to have a cleaner code.

Guillermo Oviedo
R&D Software Engineer
CLA | CTD
0 Kudos
Message 5 of 9
(2,415 Views)

@Guillermo.O wrote:

Consider using Conditional Tunnels ...It will allow you to have a cleaner code.


It will take much more than conditional tunnels to clean up that code. 😄 (I think they are probably not even needed here).

 

I am sure it all could be done with code the size of a postage stamp. 😉

(maps/variant_attributes come to mind... ;))

0 Kudos
Message 6 of 9
(2,410 Views)

@altenbach wrote:

@Guillermo.O wrote:

Consider using Conditional Tunnels ...It will allow you to have a cleaner code.


It will take much more than conditional tunnels to clean up that code. 😄 (I think they are probably not even needed here).

 

I am sure it all could be done with code the size of a postage stamp. 😉


https://www.thefactsite.com/largest-postage-stamp/ 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 9
(2,404 Views)
Solution
Accepted by topic author Caracatos

Yes, here's one possible solution using maps (note that the various output tables can be different in size. Also note the scrollbars, not all elements are shown).

 

altenbach_0-1578958260640.png

 

Maybe not the size of a postage stamp, but definitely smaller than a postcard. 😉

0 Kudos
Message 8 of 9
(2,390 Views)

Thank you !

I'm using this approach and it's works for me.
Great answer!

0 Kudos
Message 9 of 9
(2,276 Views)