+ Reply to Thread
Results 1 to 19 of 19

Try to countifs and sumifs value with "-"

  1. #1
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Try to countifs and sumifs value with "-"

    I have exported some value from MYOB, the accounting program, like this:

    Column A Value Column A *1
    6-1826 10 #VALUE!
    6-1830 10 #VALUE! =COUNTIFS(A:A,">6-1825",A:A,"<6-1899") 3
    6-1898 10 #VALUE! =COUNTIFS(A:A,">6-1900",A:A,"<6-1999") 0
    6-1900 10 153
    6-1910 10 3805 =SUMIFS(B:B,A:A,">6-1825",A:A,"<6-1899") 30
    6-1932 10 11841 =SUMIFS(B:B,A:A,">6-1900",A:A,"<6-1999") 0
    6-1951 10 18780


    Column A is the account no. exported from MYOB.
    Column B I assume each them is $10
    Column C is column A*1
    When I try to count or sum values between "6-1825" and "6-1900", it works perfect.
    But when I try to count or sum values between "6-1900" and "6-1999", it doesn't work.

    Can anyone please point out the problem, and how should I solve this?
    Thanks a lot
    Last edited by molittlemo; 08-18-2017 at 05:16 AM.

  2. #2
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Try to countifs and sumifs value with "-"

    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Quote Originally Posted by shukla.ankur281190 View Post
    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks a lot for the reply.
    Sorry I did not make it clear.
    My purpose it to sum up the value in column B given the range in column A

  4. #4
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Try to countifs and sumifs value with "-"

    Try

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


    Change the criteria ( highlighted part) according your need.

  5. #5
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Try to countifs and sumifs value with "-"

    it would be better posting a sample, if the above don't work, if I type 6-1899 in a cell thats what it stays as. however 6-1900 becomes june 1900. What actually are your values in column A. Hence a sample would be useful!

  6. #6
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Quote Originally Posted by davsth View Post
    it would be better posting a sample, if the above don't work, if I type 6-1899 in a cell thats what it stays as. however 6-1900 becomes june 1900. What actually are your values in column A. Hence a sample would be useful!
    Thanks and sorry I am new to here, not too sure how it works.
    Please see the attchment
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Thanks and please refer to the attachment.
    It does not work for any right 4 digits lager than 1900.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Try to countifs and sumifs value with "-"

    Quote Originally Posted by molittlemo View Post
    ......

    Column A Value Column A *1
    6-1826 10 #VALUE!
    6-1830 10 #VALUE! =COUNTIFS(A:A,">6-1825",A:A,"<6-1899") 3
    Any time you have any character other than just numbers in a cell, ,that cell's contents become text, so when you have something like 6-1825, that is text, even though it looks like a number. Because it is text, you cannot use > or < for any tests, thats liks asking excel if Tree is > whale.

    Probably the best way around that would be to use a helper column, and maybe convert the - to a . so that 4-1100 becomes 4.11 and 4-1440 becomes 4.144, then you CAN do a test for > or <
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Try to countifs and sumifs value with "-"

    Try with helper column

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


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


    Drag down and change the cell format in to General from Text.

    Now use

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


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

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Try to countifs and sumifs value with "-"

    Quote Originally Posted by shukla.ankur281190 View Post
    Try with helper column

    C2
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ...
    That wont work, OP beeds to be able to break the "4" range down into different levels
    =SUMIFS(B:B,A:A,">4-1000",A:A,"<4-1500")
    =SUMIFS(B:B,A:A,">4-1500",A:A,"<4-1900")
    etc
    Thats why I thought it would be better to just convert to 4.xxx

  11. #11
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Try to countifs and sumifs value with "-"

    @Mr. Ford ! I did two helper columns for the working both criteria.

  12. #12
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    But its strange that it works between 4-1000 and 4-1500 but not working between 6-2000 and 6-2100..

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Try to countifs and sumifs value with "-"

    You're own guess in cell A19 of the document you posted is correct.
    It is in fact interpreting digits 1900+ as dates.
    6-1900 becomes June 1st 1900

    You'll be best off separating the values with helper columns as suggested.
    Last edited by Jonmo1; 08-19-2017 at 10:50 AM.

  14. #14
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Thanks I will try

  15. #15
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Thanks it works perfectly~~~~

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Try to countifs and sumifs value with "-"

    Perhaps simply
    =SUMPRODUCT($B$2:$B$100,($A$2:$A$100>"4-1000")*($A$2:$A$100<"4-1500"))
    without helper columns.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  17. #17
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    Thanks.
    It seems work too~~

  18. #18
    Registered User
    Join Date
    08-18-2017
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    12

    Re: Try to countifs and sumifs value with "-"

    its interesting that "sumproduct" can identify the value larger than 6-1900 but "sumifs" can not..

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Try to countifs and sumifs value with "-"

    The difference is that Sumifs converts 6-1900 to a Date, but Sumproduct does not.

    The xxIFs family of functions are designed to treat anything that looks like it might be a numeric value as a number.
    Sumproduct itself isn't actually looking at the "4-1900" value.
    Before sumproduct even looks at the values presented to it, they are processed by straight cell comparisons and math operations.

    So you have this inside sumproduct
    ($A$2:$A$100<"6-1900")
    That is first processed as an array of true/false statements.
    Is A2 < "6-1900" <- This comparison does not convert that string to a date.
    Is A3 < "6-1900"
    Is A4 < "6-1900"
    Etc.
    You end up with an array of True's and False's
    {TRUE,TRUE,FALSE etc..}

    Then by the virtue of the multiplication action against that array, they are further converted into 1's and 0's (TRUE = 1, FALSE = 0)

    Only then does sumproduct start to work with the values by multiplying that array of 1's and 0's with the array $B$2:$B$100\
    $B$2:$B$100*{1,1,0,etc}

    Then sums those results.


    On the other hand, sumifs DOES look directly at the "6-1900" string while it is doing it's processing.
    And it gets converted to a date.

    Hope that helps.
    Last edited by Jonmo1; 08-28-2017 at 08:39 AM.

+ 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] Sumifs seems like overlook "0" and "." in front and behind a number
    By yzhen9 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-21-2017, 01:20 AM
  2. [SOLVED] COUNTIFS returning "TRUE" or "FALSE"
    By ambolton528 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-20-2016, 08:16 PM
  3. Excel formula "COUNTIFS" problem with ">"
    By danngkb in forum Excel General
    Replies: 4
    Last Post: 06-19-2014, 02:32 AM
  4. [SOLVED] Possibly Easy: Making an "Other" with Countifs; "Not this, this, or this"
    By nscarritt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2014, 11:44 AM
  5. [SOLVED] Countifs, Sumifs, is there another "ifs"?
    By Eldernurf in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-24-2013, 09:19 AM
  6. Replies: 10
    Last Post: 01-26-2012, 08:26 AM
  7. can a "MINIF" formula be built, equivalent to "SUMIFS"?
    By jrtaylor in forum Excel General
    Replies: 4
    Last Post: 10-22-2011, 12:44 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