+ Reply to Thread
Results 1 to 20 of 20

How to use COUNT functions to subtract 1

  1. #1
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    How to use COUNT functions to subtract 1

    I am trying to take the SUM of the number is the first row and divide by the COUNT of the cells that have numbers MINUS one of that COUNT.

    Any ideas?

    I can't attach a screen shot, but the data is monthly values. I want to compare the value of JUN (in this case 27) to the average of the preceding 5 months. I do not want to change manually the number of months in excel to divide by 5 as the COUNT functions bring 6. Attempts at formula simply subtract 1 from the average of the 6 months.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to use COUNT functions to subtract 1

    You get better help on your question if you add a small excel file, without confidential information.

    Please also add manualy the expected result in your file.

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    I attached an extremely rudimentary version to show the intent. Might help?

    ? How can this be set up so when a user inputs or data is pulled for follow-on months the number is auto populate
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to use COUNT functions to subtract 1

    o1 =counta($B$3:$M$3)-1
    p1 =counta($B$3:$M$3)

    03 =SUM(INDIRECT(ADRESS(3,2)&":"&ADRESs(3,2+$O$1-1)))/$O$1
    P3 =(SUM(INDIRECT(ADRESS(3,2)&":"&ADRESS(3,2+$P$1-1)))/$P$1)-$O3

    See the attached file.
    Last edited by oeldere; 08-03-2017 at 06:39 PM. Reason: foget it etc.

  5. #5
    Registered User
    Join Date
    08-28-2015
    Location
    Melbourne, AUS
    MS-Off Ver
    2011
    Posts
    59

    Re: How to use COUNT functions to subtract 1

    How's this?

    Formula for O3

    =SUM(INDIRECT(ADDRESS(3,2)&":"&ADDRESS(3,2+COUNTIF(B3:M3,"<>"&"")-2)))

    Formula for P3

    =INDIRECT(ADDRESS(3,2+COUNTIF(B3:M3,"<>"&"")-1))-SUM(INDIRECT(ADDRESS(3,2)&":"&ADDRESS(3,2+COUNTIF(B3:M3,"<>"&"")-2)))/(COUNTIF(B3:M3,"<>"&"")-1)

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,742

    Re: How to use COUNT functions to subtract 1

    Another way. I am not sure I interpreted correctly.

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

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

  7. #7
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    I probably didn't do the best job at the explaining. In the example, the yellow box would need to be 6 (the total of 30 divided by the previous 5 months) and the blue box would be 6.

    Putting in 20 for JUL should give the result of 7 (42 divided by 6 months) and the blue box would be 13. So the Blue looks good testing it out.

  8. #8
    Registered User
    Join Date
    08-28-2015
    Location
    Melbourne, AUS
    MS-Off Ver
    2011
    Posts
    59

    Re: How to use COUNT functions to subtract 1

    P3

    =indirect(address(3,2+countif(b3:m3,"<>"&"")-1))-sum(indirect(address(3,2)&":"&address(3,2+countif(b3:m3,"<>"&"")-2)))/(countif(b3:m3,"<>"&"")-1)

    o3

    =sum(indirect(address(3,2)&":"&address(3,2+countif(b3:m3,"<>"&"")-2)))/(countif(b3:m3,"<>"&"")-1)

  9. #9
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    perfect! I was not familiar with this logic at all and great to learn! Will be useful

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to use COUNT functions to subtract 1

    @donvang

    It is always good to add to whom you are replying.

    In that case forummembers will know on what solution you replied (#4, #5, #6, #8)

  11. #11
    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,879

    Re: How to use COUNT functions to subtract 1

    In O3

    =SUM(OFFSET($A$3,0,1,1,COUNTA($B$3:$M$3)-1))/(COUNTA($B$3:$M$3)-1)

    or

    =AVERAGE(OFFSET($A$3,0,1,1,COUNTA($B$3:$M$3)-1))

    in P3

    =OFFSET($A$3,,COUNTA($B$3:$M$3))-$O$3
    Last edited by JohnTopley; 08-04-2017 at 11:12 AM. Reason: Thought I posted the AVERAGE formula earlier!!

  12. #12
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to use COUNT functions to subtract 1

    Or just:
    In O3:
    =AVERAGE(OFFSET($B$3:$M$3,0,0,1,COUNT($B$3:$M$3)-1))

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

  13. #13
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    Response 8 worked. I just made one simple change to look for values greater than 0 as total will always be 0.

    I now run into issue try to find value comparing the month % to the cumulative % for the months prior. I attached a file that explains. Would appreciate insight. What I am trying to do is quickly compare the current month value to the previous months averages.

    I am curious to test out the COUNTA function as that is the route I was trying for a few hours last week.

  14. #14
    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,879

    Re: How to use COUNT functions to subtract 1

    No file attached.

    Attach a sample workbook (not image).

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.

    Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  15. #15
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    correct file attached. computer issues.
    Attached Files Attached Files
    Last edited by donvang; 08-05-2017 at 02:05 PM.

  16. #16
    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,879

    Re: How to use COUNT functions to subtract 1

    From your file (removing #DIV0! error then compare in Q4 would be July/ Jun.

    However as you data in all months in row 5 there is no method of testing which is current month.

    and this applies to Q5

    in P2

    =AVERAGE(OFFSET($B2,0,1,1,COUNTIF($C2:$N2,"<>0")-1))

    in P3

    =AVERAGE(OFFSET($B3,0,1,1,COUNTIF($C3:$N3,"<>0")-1))

  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,879

    Re: How to use COUNT functions to subtract 1

    Put this in C5 and copy across

    =IF(C3=0,0,SUM($C3:C3)/SUM($C2:C2))

    in C4 and copy across

    =IFERROR(C3/C2,0)

    in Q4

    =OFFSET($B4,,COUNTIF($C4:$N4,"<>0"))-OFFSET($B$5,,COUNTIF($C5:$N5,"<>0")-1)

    in Q5

    =OFFSET($B5,,COUNTIF($C5:$N5,"<>0"))-OFFSET($B$5,,COUNTIF($C5:$N5,"<>0")-1)

  18. #18
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to use COUNT functions to subtract 1

    I'd go a different route. Make "future" cells BLANK and use COUNT to find used columns.

    New formulas:
    C2 =IF(SUM(C6,C10,C14)=0,"",SUM(C6,C10,C14))
    C3 =IF(C2="","",SUM(C7,C11,C15))
    C4 =IF(C2="","",C3/C2)
    C5 =IF(C2="","",SUM($C3:C3)/SUM($C2:C2))
    Copy all 4 across columns C:N.
    Then copy C4:N5 and paste in C8:N9, C12:N13, C16:N17
    Summary formulas:
    Q4 =INDEX(C4:N4,,COUNT(C4:N4))-INDEX(C5:N5,,COUNT(C4:N4)-1)
    Q5 =INDEX(C5:N5,,COUNT(C5:N5))-INDEX(C5:N5,,COUNT(C5:N5)-1)


    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Attached Files Attached Files
    Last edited by leelnich; 08-05-2017 at 03:30 PM.

  19. #19
    Registered User
    Join Date
    08-03-2017
    Location
    wisconsin
    MS-Off Ver
    2013
    Posts
    8

    Re: How to use COUNT functions to subtract 1

    #18 worked perfectly, much appreciated and learned quite a bit from example. Will keep this in my toolkit as method to determine current month data to previous months

  20. #20
    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,879

    Re: How to use COUNT functions to subtract 1

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Subtract 2 sums/functions?
    By Emma Frost in forum Excel General
    Replies: 4
    Last Post: 04-01-2015, 07:51 AM
  2. userform calculations (Count, Sum, Subtract) treaky one
    By intex in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-17-2014, 06:42 AM
  3. Using formula for count, but not able to subtract unneeded information
    By Nina2VC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2013, 11:56 AM
  4. Replies: 1
    Last Post: 01-27-2012, 11:25 PM
  5. if functions to add and subtract values in 2 or more different cells
    By Mengo85 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2010, 10:09 PM
  6. Creating a macro to add and subtract from a standing count
    By kung in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-06-2009, 05:02 PM
  7. Add and Subtract functions
    By Graham Moran in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-30-2006, 09:40 PM

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