LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save me from my rube

Solved!
Go to solution

I want to total all data that happens on the same date. It's making me cringe that I haven't come up with another solution. May God have mercy on my soul.

 

 

Message 1 of 15
(4,198 Views)
Solution
Accepted by topic author GregFreeman

Nothing adds flair quite like a variant.

 

GoodbyeRubeyTuesday.png

Message 2 of 15
(4,185 Views)

I don't have 2010 installed to try your snippet, but maybe you'd prefer to sort the original array first, something like this:

Sort and Sum array columns.png

Message 3 of 15
(4,158 Views)

Another Potential Solution

 

Number of iterations = number of different dates

Rube2.png

Greg Sussman
Sr Business Manager A/D/G BU
Message 4 of 15
(4,109 Views)

If you're using a database, I would suggest a simple GROUP BY and SUM combo in a query.

 

If not, and your main concern is aesthetics, OpenG is your friend:

 

Sum Date.png

 

 

It's probably not particularly efficient, and I haven't tested it, but it certainly is clean.


___________________
Try to take over the world!
Message 5 of 15
(4,092 Views)

Thanks for all the viable solutions! I appreciate it!

0 Kudos
Message 6 of 15
(4,044 Views)

Darin, I really like the variant solution.  Very cool ... and quite a bit faster that the OpenG method.

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 7 of 15
(4,034 Views)

I wanted to post this because I used Darin's method to go a bit more in depth. I wanted to group by multiple things such as "Category 1" Sub Category 1 -> Total

 

"Category 1" Sub Category 2 -> Total etc. So...here is my solution, let me know if it can be improved

 

0 Kudos
Message 8 of 15
(3,995 Views)

@for(imstuck) wrote:

...let me know if it can be improved 


Think of the Variant Attribute Name as a throw-away UID, and you can just start mashing together identifiers (using concatenate) rather than creating a hierarchy of variants of variants:

 

JRD-EditVariant.png

 

BTW - Cool solution, Darin! :thumbup1: And everyone vote for kegghead's Idea to make Variant Attribute atomic access cleaner syntactically (and faster?)!

Message 9 of 15
(3,975 Views)

To add an extra layer of protection against collision, when I concatenate strings to form an attribute tag I will add a separator (tab,pipe,etc.) that I do not expect to appear in the names themselves.  What comes in handy in many cases is my old friend Join Strings.vi.

 

Edit:  Was I the only one pleasantly surprised that the Variant To Data function happily dealt with an array of variants?  I can de-rubify some of my VIs now.

0 Kudos
Message 10 of 15
(3,965 Views)