Jump to content

How to replace "0" for all empty cells in between two non-empty cells of table in Labview?


Recommended Posts

Hello ! I've been trying to solve this problem for two days and I really need help on this.

So I have a weekly progress table as below :

As long as there's already a non-empty column for the PES #, the rest of the empty column after that non-empty column needs to show 0%. How should I do this?

image.png.50c4e83c234c5092f46510a23c13546f.png

 

I need to make it into this table as below:

image.png.5d7974d5c359bc5a75b269cb40b099b0.png

 

Thank you so much in advance !

Edited by Yean95
Link to comment
4 hours ago, Yean95 said:

Hello ! I've been trying to solve this problem for two days and I really need help on this.

So I have a weekly progress table as below :

As long as there's already a non-empty column for the PES #, the rest of the empty column after that non-empty column needs to show 0%. How should I do this?

image.png.50c4e83c234c5092f46510a23c13546f.png

 

I need to make it into this table as below:

image.png.5d7974d5c359bc5a75b269cb40b099b0.png

 

Thank you so much in advance !

Can you post what you have done so far?

Link to comment
1 hour ago, Neil Pate said:

Can you post what you have done so far?

Below is what I've done but it's quite messy though. My original table is a non-pivoted table, so the front part of my labview gives the result of the first table in which the table is pivoted.

The last for loop is where I'm stucked.

 

image.png.27be935fc764279c0da57f7d8b4a7990.png

Link to comment

Yup, that's pretty messy.

One mistake: you don't have auto indexing on the input but do have on the output of the outer loop. Or the code is that messy I misunderstood.

I would use auto indexing, and have a bool flag (shift register) inside the outer loop. Init it to false and set it to true if the cell is not emply (otherwise don't change it's value). Then fill the cell with "0%" if it's empty AND the flag is true. 

Link to comment

I'll leave the logic to others for now, but here are a couple of initial observations:

1) If these tables can get larger you might consider making the table cell formatting more efficient: Defer front panel updates (updating table GUI for each step is extremely slow) then format the table cells and headers in one go before you reenable front panel updates. If all rows of all columns are to have the same format anyway (empty ones can get the same as they are empty anyhow) you might as well set the active cell to -2,-2 and apply to all. If the headers are to be different you can then apply a reformatting of all of them afterwards using a -1, -2 combo (kudo this idea to avoid that last step in the future...).

2) The OpenG toolkit has "Remove Duplicates" and "Sort 2D array" functions you could use to get the unique and sorted week and models. If you have LabVIEW 2020 the same functions are available as VIMs on the array palette.

3) Avoid the repeated searches, e.g. by running an auto-index-driven set of for loops and simple equal or not checks instead.

As others have mentioned already using a feedback node / shift register to keep track of whether to insert a 0% or not is likely to be part of the solution. Personally I would probably be lazy and just initialize the whole table with 0% and leave it at that 😄, but that might be misleading here...and not as pretty. Working from the bottom up filling in 0% on empty cells after the last entry has been found (state kept in feedback/shift reg) is another idea. The fact that you want to fill APR W3 all the way down to the end of APR W2 makes it necessary to include the state (end index) from the previous column as well though, not just whether or not there is an entry lower in the same column.



 

Link to comment

I just couldn't resist. Not optimized in any way, but I guess for data that has to be visualized, this is not a problem.

image.png.f69e6d0f4b670a4784c6a673c582911d.pngimage.png.d179caf3a00e3ea337bb40ce2225e6dd.png

Edited by Lipko
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Andersen Chen
      hello everybody,
      i want to index column 0~39,how to achieve and simplify
      thank you for help
      array.vi
    • By bingbot
      1: How to get last index, not last element, but last index number of an 2d array?
       
      Also
       
      2: say 2d array has contents
       
      elephant  crow    dog      goat
      giraffe      eagle   cat       fly
      ant          pig        horse   bee
       
      How to get that the bee is the 12th or 11th index in the array? (11 if you count elephant as zero index, 12 if you count elephant as first index), meaning I want the index number 11 or 12, not "bee"
    • By pkeny
      Hello,
       
      I am having trouble on learning what to do after you input a file into labVIEW. I cannot seem to find help on this topics. I have seen many videos and tutorials on how to read and write excel/text (.csv) files. But, I am not able to do anything after importing an text/excel file into labVIEW.
       
      So, I was wondering if someone had a simple VI that they could share. In the end, I want to do some automation so it will read a number and a status from excel. And then that number and status will either turn on or off a switch which controls something else. 
       
      Anyways, I would greatly appreciate if someone could share a VI as an example of how to manipulate the data to control something after you import a text/excel file into labVIEW.
    • By chris754
      (If this is not the right forum, please move as appropriate)
       
      Yesterday, I was trying to capture the "key down?" event on a string array control. I noticed that the event would never get fired while typing into one of the strings in the array. The event does fire if you type in the index control of the array. My question: Is this expected behavior or a bug? After trying a few things, I can get the behavior I want by getting a reference to the "ArrElem" and registering it for the "key down?" event and passing the into the dynamic event terminal. This is fine for my purposes and will implement my code in this fashion. However, I certainly was not expecting this event to behave in this way. I guess I could see why this may be the case (you are typing into a string control, not an array) but curious what other people think...
       
      This was all done in LV2013.
       
      Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.