+ Reply to Thread
Results 1 to 32 of 32

Conditionally sum fractional cells based on column headings

  1. #1
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Conditionally sum fractional cells based on column headings

    Hi there, I am looking for an Excel formula that will will sum fractional values (test scores) in cells based on whether the column headings in the range equals the heading in the summation column. I need to sum the numerator and denominator separately (i.e. 5/6 + 2/2 = 7/8)

    Below is an example:

    excel example.png

    So in Cell M6, I need a formula that will sum the fractional values (numerator/denominator separately as shown in above example) in the range G6:L6 conditionally based on whether the column headings for the same range (G5:L5) match the value given in cell M5. So the formula in M6 would evaluate that in M5 we have a value "OA.2" and that value appears in the range (G5:L5) in cells G5 and J5, so we would sum the values 1/3 and 2/5 together to get 3/8

    I also need the values in the cells to be shown as fractions, i.e. 4/4 stays as 4/4 (but can still be used for calculation purposes). I've found that Excel was trying to convert this be 1, unless I formatted as Text in which I don't believe I can do calculations on it.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,401

    Re: Conditionally sum fractional cells based on column headings

    It would help if you attached a sample Excel workbook, and you can do that by following the guidelines in the second yellow banner at the top of the screen.

    Hope this helps.

    Pete

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,075

    Re: Conditionally sum fractional cells based on column headings

    I think you need to study your maths again.
    Whn adding fractions you can't just add the top numbers and the bottom numbers together, ie

    1/3 + 4/12 is not 1+4 divided by 3 + 12, ie 5 / 15 That's wrong! 5 /15 is 1/3, so how can 1/3 + another non zero number still be 1/3 ???
    Fractions don't work like that.

    You need to find a common denominator to add them.
    In the above the common denominator is 12
    So 1/3 = 4 /12
    So 4 /12 + 4 /12 = 8 / 12 = 2 / 3

    Google "adding fractions"
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so. Cross-posts are allowed but you must provide a link to your posts on other sites.
    For new members: you will not be able to post a full URL, so remove the https://www. section and add one or two breaks to the rest of the address. A Moderator or Admin will then fix the link for you.

    Please see Forum Rule #7 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. No help to be offered until you provide a link or, for members with fewer than 10 posts, a comment telling us where else you have posted this query.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Hi, yes I posted on Mr.Excel. It will not let me add a link here though it says until I've posted a few times...


    I am aware this is not true fractional math, and rather summing of the individual parts (numerator/denominator) for test scoring.

    I have also attached a sample excel file below:

    excel_sample.xlsx

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    Here's a link:

    https://www.mrexcel.com/board/thread...dings.1267547/

    Are you still using Excel 2007?

  7. #7
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    I am well aware of how fractions work, and I explained the requirement in the original post.
    Last edited by AliGW; 12-05-2024 at 10:44 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead. Please review the forum guidelines.

  8. #8
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Hi @AliGW , I am using Excel 2021 actually. I will update that on my profile.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    The problem is that Excel is seeing the scores as fractions, so for example 1/3 is actually 0.33333...

    I would encourage you (as a retired teacher) to change the way that you enter scores. Add a row below the unit name and add the maximum score for each test. In the actual score cells, give just the score and not what it's out of.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    For example, in M7:

    Please Login or Register  to view this content.
    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    G
    H
    I
    J
    K
    L
    M
    5
    OA.2
    OA.3
    OA.3
    OA.2
    OA.3
    OA.4
    OA.2
    6
    3
    6
    4
    5
    3
    8
    7
    1
    5
    4
    2
    2
    3
    3/8
    Sheet: Sheet1

  11. #11
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,612

    Re: Conditionally sum fractional cells based on column headings

    I think you need to study your maths again.
    Maybe he means this

    1/3 means 1 out of 3 questions answered correctly
    2/5 means 2 out of 5 questions answered correctly


    Together :
    3/8 3 out of 8 questions answered correctly
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    That is correct, but Excel sees 1/3 as 0.33333 recurring, and not as a text entry of 1/3. Hence my suggested workaround above.

  13. #13
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    I wonder if I need to add some helper columns and use LEFT and MID Excel functions to extract what the numerator and denominator would be, place them into their respective columns, and then
    do the summations and combine together. Seems like it may get kind of messy but I'm not seeing an alternative.

  14. #14
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Unfortunately I can't change the format of how the data (scores) are being entered. The data is coming from another system and the end-users of the spreadsheet (Teachers ) don't want to do any manual manipulation of the data and just want to copy and paste it as-is.

  15. #15
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Updated Excel file attached with formula.

    excel_sample2.xlsx

  16. #16
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Hi AliGW - I tried this formula but for some reason it is resulting in 0.7333/0.7333 for the values with 'OA.2'. I would expect this to result to 3/8 instead. I've attached the updated Excel file (excel_sample2.xlsx) with this formula for you.
    Last edited by AliGW; 12-06-2024 at 02:14 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead. Please review the forum guidelines.

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,539

    Re: Conditionally sum fractional cells based on column headings

    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Results in M & N are fractions
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  18. #18
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Hi, I tried this but the math doesn't seem to add up correctly for OA.3 (or for OA.2 if I change any of the existing values). Based on the below values, for OA.3, it should be a total of 11/13



    OA.2 OA.3 OA.3 OA.2 OA.3 OA.4 OA.2 OA.3
    2/3 5/6 4/4 2/5 2/3 3/8 1/2 5/6

    Also if I switch the Value in G6 (for first OA.2 column) to be 2/3 , then the total for OA.2 changes from 3/8 (correct) to 1/2 (incorrect). What are your thoughts?
    Last edited by AliGW; 12-06-2024 at 02:13 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead. Please review the forum guidelines.

  19. #19
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,291

    Re: Conditionally sum fractional cells based on column headings

    I see a mix of numbers and text (unit fractions like 4/4 get stored as text strings). All examples also show ratios where both numerator and denominator are less than 10 (single digit). Assuming those two observaations are universally true, I:

    1) An IF() function to test for text/number. If text, then copy the value down. If number, convert to text in "0/0" format. =IF(ISTEXT(G6),G6,TEXT(G6,"0/0")). In G8. Copy/paste/fill across.
    2) Extract numerator from text and convert to number. =VALUE(LEFT(G8,1)) in G9. Copy/paste/fill across.
    3) Extract denominator from text and convert to number. =VALLUE(RIGHT(G8,1)) in G10. copy/paste/fill across.
    4) With numerator and denominators separated into separate rows, the conditional summations are easy with a SUMIFS() function. =SUMIFS($G9:$L9,$G$5:$L$5,M$5) in M9. Copy into M9:N10.
    5) If it is necessary to combine into a single fraction, I would combine as text =M9&"/"&M10 in M11. Copy into N11.

    It's basically AliGW's strategy of separating numerators and denominators so you can sum them independently. I haven't tried nesting that into a single cell function. Adjustment would need to be made for the possibility of 2 digit numerators/denominators.

    Would something like that help?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    Expanding on John's suggestion, this seems to work:

    =SUMPRODUCT((LEFT($G6:$L6,1))*($G5:$L5=M$5))&"/"&SUMPRODUCT((RIGHT($G6:$L6,1))*($G5:$L5=M$5))

    and so does this:

    =SUMPRODUCT((LEFT($G6:$L6,FIND("/",$G6:$L6)-1))*($G5:$L5=M$5))&"/"&SUMPRODUCT((MID($G6:$L6,FIND("/",$G6:$L6)+1,4))*($G5:$L5=M$5))

    The advantage here is that it won't matter how many digits are either side of the /.
    Attached Files Attached Files
    Last edited by AliGW; 12-06-2024 at 02:19 AM. Reason: Workbook added.

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,539

    Re: Conditionally sum fractional cells based on column headings

    I had this originally (as per AliGw's post)

    Please Login or Register  to view this content.
    but changed to try and avoid the answer being text (but did not spot the error in OA.3 ... my bad!)

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    These are not traditional fractions, so not treating them as text is never going to work. This is what I was trying to get at earlier in the thread.

    The data is coming from another system and the end-users of the spreadsheet (Teachers ) don't want to do any manual manipulation of the data and just want to copy and paste it as-is.
    I was a teacher and Head of Department for 30 years. Teachers are some if the best learners on the planet: if you take the time to explain the problem here and give them a simple template for data entry in the format I suggested, they will adapt perfectly well. It's all very well blaming them, but if you aren't willing or able to persuade them to adjust their data entry, then you are as much of the problem as they are. You are working in an educational environment, so educate them. I've been there and done it, so don't tell me it's not possible.

    By the way, my subject was languages, and if a languages team can be converted, so can any department. You are setting yourself up for a whole world of pain when you want to start analysing this data. You really do need to bite the bullet and get them to change their practices instead of trying to work with improper data entry. And you need to park the 'us and them' attitide: one of the biggest problems in schools is when the IT team and the teaching staff (Heads of Department) don't work together as a team. Because I am a bit of an Excel nerd, I was fortunate enough to be able to help bridge that gap for the whole school: you need to find an ally on the teaching staff, preferably a manager or middle manager, and make it a bit of a crusade. As I said, I've been there and done it. Make it your New Year's resolution. Good luck!
    Last edited by AliGW; 12-06-2024 at 05:06 AM. Reason: Typo fixed.

  23. #23
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,539

    Re: Conditionally sum fractional cells based on column headings

    And let it be noted that there is no more delicate matter to take in hand, nor more dangerous to conduct, nor more doubtful in its success, than to set up as a leader in the introduction of changes.
    Machiavelli.

  24. #24
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    LOL! Well, one thing's for sure: if you don't try, you don't progress. Someone has to be the one to stick their head above the parapet, and I guess that was me in my career. It landed me with a lot of extra work, but I did effect change, and for the better, so I'm pretty proud of that. I think old Machiavelli was a bit of an extreme case - I wasn't in his league ...

  25. #25
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,539

    Re: Conditionally sum fractional cells based on column headings

    I wholeheartedly agree with your post #22: and the key word is LEADER [the one to stick their head above the parapet] as you obviously were in your career.

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    Thanks - yes, I suppose I was. Certainly in the vanguard if not right in front!

  27. #27
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,169

    Re: Conditionally sum fractional cells based on column headings

    Try this in M6:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  28. #28
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    TEXTBEFORE and TEXTAFTER are NOT available in 2021 - 2024 and 365 only.

    Please bookmark this site for your future reference: https://bettersolutions.com/excel/fu...-functions.htm

  29. #29
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,169

    Re: Conditionally sum fractional cells based on column headings

    Try change to:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    https://www.mrexcel.com/excel-tips/e...fic-delimiter/

  30. #30
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,169

    Re: Conditionally sum fractional cells based on column headings


  31. #31
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    89,941

    Re: Conditionally sum fractional cells based on column headings

    Thanks for the links - my point is that the OP does NOT have 2024 (or 365), but 2021, which does not have those two functions. I don't need to know how to use them (I already know - I use 365), but thanks. I also offered an alternative in post #20.

    New functions in 2021: https://bettersolutions.com/excel/fu...-functions.htm

  32. #32
    Registered User
    Join Date
    04-14-2011
    Location
    NY
    MS-Off Ver
    Excel 2021
    Posts
    17

    Re: Conditionally sum fractional cells based on column headings

    Thanks @AliGW and everyone else! I've tested this by changing the values within the range and this appears to work great.

    You're preaching to the choir regarding educating the other teachers she's supports as an Instructional Coach! Enacting change in her school district is very difficult, especially with not being in a supervisory role and with Unions being involved. That's a whole other conversation though, haha.

    Thanks again all for jumping in and offering great solutions for this!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 06-28-2018, 11:20 PM
  2. Replies: 1
    Last Post: 07-20-2015, 02:27 PM
  3. Replies: 1
    Last Post: 04-04-2013, 02:47 PM
  4. Replies: 5
    Last Post: 10-26-2011, 11:57 AM
  5. Replies: 2
    Last Post: 07-23-2010, 10:11 AM
  6. Replies: 23
    Last Post: 09-25-2009, 07:39 PM
  7. Replies: 1
    Last Post: 09-19-2009, 08:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1