01-24-2011 05:35 PM - edited 01-24-2011 05:36 PM
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.
Solved! Go to Solution.
01-24-2011 05:56 PM
01-24-2011 06:32 PM
I don't have 2010 installed to try your snippet, but maybe you'd prefer to sort the original array first, something like this:
01-25-2011 12:30 AM - edited 01-25-2011 12:32 AM
Another Potential Solution
Number of iterations = number of different dates
01-25-2011 01:46 AM
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:
It's probably not particularly efficient, and I haven't tested it, but it certainly is clean.
01-25-2011 07:58 AM
Thanks for all the viable solutions! I appreciate it!
01-25-2011 08:29 AM
Darin, I really like the variant solution. Very cool ... and quite a bit faster that the OpenG method.
01-25-2011 10:41 AM - edited 01-25-2011 10:43 AM
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
01-25-2011 11:30 AM
@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:
BTW - Cool solution, Darin! And everyone vote for kegghead's Idea to make Variant Attribute atomic access cleaner syntactically (and faster?)!
01-25-2011 11:41 AM - edited 01-25-2011 11:50 AM
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.