LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count the number of repetitions of items

Solved!
Go to solution
I want to count the number of repetitions in column 2, that correspond to each category in column 1 in a table. The repetitions in col 2 should be of the same item, so I would get the reps by category and by item.
Can someone please help me?
Thanks in advance.
0 Kudos
Message 1 of 22
(2,444 Views)

Could you supply some example data that show the input and what you expect as an output.  Preferably, do this with a VI by setting the values and then setting them as default before posting the VI.


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 2 of 22
(2,418 Views)
This is what I want to do in labview:
https://docs.google.com/spreadsheets/d/1sHHMLi7zk-c_AyPB0tuFVqINjMZPlojkOoyYnhCJKu8/edit?usp=drive_w...
The example is in excel.
Thanks in advance.
0 Kudos
Message 3 of 22
(2,409 Views)

Showing us the Spreadsheet was helpful in understanding the problem.  Why don't you look at the Spreadsheet and think (not in terms of LabVIEW, necessarily) what steps you would take to solve the problem.  For example, I thought of "Do something with Column 1", "Do something with Column 2", then "Process each row".

 

Now once you have a "thought algorithm" in mind, think about how you might implement that in LabVIEW.  What sort of data structure(s) would be helpful?  How would you use them to carry out the steps of your Thought Algorithm?

 

Now try writing the code.  If you get stuck, attach your code (and it would also help to attach the data file you are trying to analyze so we don't have to "make it up ourselves").

 

Bob Schor

 

P.S. -- if you do attach code, attach it as a VI or a LabVIEW Snippet, something we can edit and execute.

0 Kudos
Message 4 of 22
(2,391 Views)

What you want to do is simply a 2D histogram.

 

Get all unique entries from each column and assign them an index.

Initialize a 2D I32 array with sizes corresponding to the number of unique items

Iterate over all rows and increment the Corresponding array element with each iteration.

Create a table where the row and column headers correspond to the unque entries and the body of the table contains the counts.

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 22
(2,377 Views)

I understand what you are saying, but I still have a problem.

I started making some progress, but the thing is I have to columns not just one, and I eliminated the repetitions in both, but now I don't know how to make the comparison, and add the values to a table. I will leave the vi in the description.

Any help will be greatly appreciated.

Thanks.

0 Kudos
Message 6 of 22
(2,342 Views)

OK, to get a column, you would just use "index array". No loops needed. 😄

 

See if the attached example can give you some ideas.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 7 of 22
(2,328 Views)
What I need is the number of repetitions for each item, not just a single column.
Thanks in advance.
0 Kudos
Message 8 of 22
(2,310 Views)
I am looking something like this, but I need to find items in 2 columns. In the forst col we have the category and in the second col, we have the item, so I need the item count by category.
https://decibel.ni.com/content/docs/DOC-9801
0 Kudos
Message 9 of 22
(2,305 Views)

Several days ago, I gave you an algorithm to do what you describe.  I'll do it again:

  1. Process Column 1, making an Array of all unique Categories.
  2. Process Column 2, making an Array of all unique Items.
  3. Make a 2D "Histogram" array whose rows correspond to number of Categories and columns respond to number of Items.
  4. Process each Row, incrementing the Histogram entry corresponding to that particular Category and Item.

Try coding this up yourself.  It is not difficult if you have a basic understanding of LabVIEW, loops, Arrays, and String processing (particularly telling if strings are equal or not, thinking about "Does Upper/Lower Case matter?").

 

Bob Schor

0 Kudos
Message 10 of 22
(2,291 Views)