Forum Discussion
Help with data calculations
- Apr 27, 2020
Have been following this thread, without really digging in to the detailed issues. Your latest post triggered me to offer a formula that answers the very specific question. Assume that the string of numbers "8,8,6,6,4,4" sits in A1, the following formula will return 36.
=SUM(IFERROR(--(MID(A1,SEQUENCE(LEN(A1),1,1),1)),0))
Reading this from the inside out:
1) Create and array of numbers based on the length of the text string (SEQUENCE);
2) Separate the text string into its individual characters;
3) "Translate" each character into its number value, using "--". This will result in #VALUE! for the commas and real numbers for the numbers that were stored as texts;
4) If step 3 results in an error, then return zero. Now, you have an array of 11 real numbers like
{8, 0, 8, 0, 6, 0, 6, 0, 4, 0, 4}
......that can easily be summed with SUM.
Now, I do remember reading that there also may be text strings like "5-7" representing 5 or 6 or 7 reps. The above formula will then return 12, which obviously is not the desired answer. Perhaps a coding with only one number can be used. Like "n5" could be used to indicate a minimum of 5, but you may do two more. Or "x7" to indicate a maximum of 7, but you may do two less. Or "≈6" which could mean 6 plus or minus 1. These will then add up to 5, 7 or 6, respectively using the above formula.
Yeah! My formula doesn't work with 10's and 12's. Sum 1 and 0 and you get 1. Grrr.... Said I didn't go into the details.
It did leave me curious as to whether a small change to the formula would enable it to handle two or three digit numbers.
Edit: Or could you enter 10 as 5+5. Trying to be creative.
🙂
I thought about that at the time. Sadly, I don't think it meets Josie's clients' needs. If it does, though, it clearly could work.
@JosieL? Something else to ask your clients about.
mathetes Hi. I have just caught up with all these messages. I haven't looked at what you have done on the spreadsheet yet. I will do that next. I just wanted to say how much I appreciate your help. This is a very steep learning curve for me so I am very grateful. With regard to the awkward reps e.g. 2-4 ,15-20 etc. I have spoken to them about this issue this morning because it was something I was thinking about a lot last night. We have agreed that we can use the largest number in each of those ranges. However I do think that your idea of having some cells that they can fill manually would be the way forward in reality. They are bound to want to do something that doesnt fit at some point!!