07-11-2017 08:54 AM - edited 07-11-2017 09:14 AM
Hi,
I am trying to sum up where ASSET 1 have the same values. To simplify the ending array. Final result should be
ASSET 5 --20
ASSET 1 --- 21 (sum of all the values (7 X 3))
ASSET 9 ----10
Can you help me...I cant seem to get my head past where I am .. Lead me in the right direction
I attached the code
Update:
new code uploaded
Solved! Go to Solution.
07-11-2017 09:01 AM
Hi ritch,
in your VI you only use string arrays. How do you want to "add" strings?
Also there are no example/default data set in the VI…
What's the point of the uninitialized shift register when its content is cleared in the FALSE case?
I am trying to sum up where ASSET 1 have the same values.
So you want to sum up whenever you find "ASSET 1" with the very same value in the next element? Or do you want to sum up all "rows" (?) with "ASSET 1" as first element???
Anyway: filter all rows according to your requirements, then sum up the values needed…
07-11-2017 09:08 AM - edited 07-11-2017 09:15 AM
Hi,
I tried to use the shift register to compare the strings and see if previous string equal to the next one. If it's true then I'd add the values of the previous to the next one and feed it into a shift register and continue the same process. That' was my attemp but it didnt not work.
I apologize about the default data. I will reupload it.
Yes I want to only add the values where there is Asset 1. Meaning if previous iteration is Asset 1 and next one is Asset. Add the two values together. If there's 7 Asset 1. Add all 7 together..
New code with default data is uploaded
07-11-2017 09:40 AM - edited 07-11-2017 09:48 AM
'm going to save you a bit of trouble but, in return. Please explain how this works for other members. Deal? You'll learn a bit talking it through
Edit the first loop was not needed
07-11-2017 10:03 AM
Strings and numeric array pre initialized. you're using a 1D array and index through it using a for loop while searching for a strings in the 1D array pre initialized. If the search 1D function return 0, you select the 1st element form the numeric array and add +1 to it and feed it back in the shift register and build an array of cluster with the 1D string array and numeric array.
If search 1D array return -1, build am array of strings and numeric and feed to the shift register...
07-11-2017 10:56 AM - edited 07-11-2017 11:00 AM
am i misreading jeffs snippet, or does he only count how often the string occurs?
anyways ..i wanted to have fun myself .. so above is my solution
:cheers:
ps: i suggest the same deal 😉
07-11-2017 11:18 AM - edited 07-11-2017 11:24 AM
@jwscs wrote:
am i misreading jeffs snippet, or does he only count how often the string occurs?
anyways ..i wanted to have fun myself .. so above is my solution
:cheers:
ps: i suggest the same deal 😉
Why yes I missed the spec!
Not as neat as it could be. Tip: Any time you find a comparison output wired to a case selector And the input to the compare is on a tunnel of that same case. Think about the Rube Goldberg thread you might show up as a victim String to Number functions work on arrays. Nice job though
EDIT: My eyes popped out when I look again. Get rid of the Transpose and wire the "2" to the Col input leaving Row unwired will slice by column
07-11-2017 01:15 PM - edited 07-11-2017 01:38 PM
Often, Variant Attributes offer an elegant and efficient solution:
And quoting Jeff from above: "Please explain how this works for other members. Deal? You'll learn a bit talking it through" 😄
(Note that variant attribute operations (lookup, insert, etc.) are O(logN) (details), while searching an evergrowing array over and over from the beginning goes with: O(N²) and will thus be limiting for very large arrays.)
07-11-2017 01:45 PM
Hi,
would you mind saving that in LV2014 for me please.
07-11-2017 01:51 PM
Captured in 2013
And @CA Thats nifty