+ Reply to Thread
Results 1 to 13 of 13

Thread: COUNTIF to determine "Transitions"

  1. #1
    Registered User
    Join Date
    05-18-2010
    Location
    Zurich
    MS-Off Ver
    Excel 2007
    Posts
    12

    COUNTIF to determine "Transitions"

    Hi,

    I uploaded an example file here, it consists of several rows of numbers from 1-4:
    http://rapidshare.com/files/442388079/notekeysB101.xlt


    Now what I need from this sequences of numbers, is the average transition percentage (from any cell to the neighboring cell to the right of it) for
    1->1, 1->2, 1->3, 1->4, 2->1, 2->2, 2->3,... etc. (16 possibilities).

    I guess this can be done with a countif command, but somehow I can't get it to work when I select criterias involving two cells...
    Is there a way around it?

    Ideally, I would need just a set of 16 formulas, that I can copy to other files because I must evaluate dozens of these worksheets. Also note, the number of rows and columns vary.
    Last edited by DonkeyOte; 01-13-2011 at 02:04 PM. Reason: modified title

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,202

    Re: How to use COUNTIF with complicated criteria

    Can you upload example excel workbook here, on forum?
    "Relax. What is mind? No matter. What is matter? Never mind!"

  3. #3
    Registered User
    Join Date
    05-18-2010
    Location
    Zurich
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to use COUNTIF with complicated criteria

    ok here it is
    Attached Files Attached Files

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,202

    Re: How to use COUNTIF with complicated criteria

    I'm not sure what you exactly want (or where)...

    But, since you take all possibilities won't number of those transactions be COUNT(column) - 1 ?
    "Relax. What is mind? No matter. What is matter? Never mind!"

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: How to use COUNTIF with complicated criteria

    It's not very clear in terms of where you want the results ?

    If the results are meant to be conducted line by line or using the block in it's entirety ?

    If the latter it's not clear if the first value of row below counts as a transition from the last number present two rows above ?

    Using your sample... assuming analysis of entire set but where each line is separate from the last (ie no "rolling transition")

    A49:A64
    1.1 to 4.4 (stored as numbers - decimal so perhaps 1,1 to 4,4 for you)
    Assuming then use of XL2007 (implied by profile if not by file)

    B49:
    =COUNTIFS($B$2:$BY$46,INT($A49),$C$2:$BZ$46,ROUND(10*MOD($A49,1),0))
    copied down
    (again change all delimiters as necessary)
    the above would generate a breakdown of the 988 transitions that take place:

    1.1	52
    1.2	47
    1.3	47
    1.4	47
    2.1	50
    2.2	119
    2.3	73
    2.4	53
    3.1	50
    3.2	75
    3.3	121
    3.4	55
    4.1	41
    4.2	52
    4.3	61
    4.4	45
    If you are not using XL2007 then you can not use COUNTIFS - let us know.

  6. #6
    Registered User
    Join Date
    05-18-2010
    Location
    Zurich
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: COUNTIF to determine "Transitions"

    Eventually I want to create a markov chain, I have these 4 states and I need to know the transition percentages between them: how often does it go from 1 to 2, or from 2 to 3 etc...

    count column doesn't work here, these numbers are in no specific order, they are just random measurements.

    as an example: row two is a particular time period where 43 consecutive states were measured. It starts with a 3 and goes into a 4. just by looking at it, this transition happens only once here, so the percentage 3-->4 would be 1/43.
    now I want to do this for all 12 possible transitions between the 4 states and averaged over all rows.

  7. #7
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: COUNTIF to determine "Transitions"

    Quote Originally Posted by lexluthor View Post
    count column doesn't work here, these numbers are in no specific order, they are just random measurements.
    I have no idea what the above comment relates to I'm afraid - it has no relevance to the formula I posted.

    Quote Originally Posted by lexluthor
    as an example: row two is a particular time period where 43 consecutive states were measured. It starts with a 3 and goes into a 4. just by looking at it, this transition happens only once here, so the percentage 3-->4 would be 1/43.
    now I want to do this for all 12 possible transitions between the 4 states and averaged over all rows.
    Surely there are 2 transitions from 3 to 4 on row 2 - B2:C2 and AD2:AE2 ?

    In the results I posted 3.4 is 55 - this means across all rows there are 55 transitions from 3 to 4, on a row by row basis:

    2
    1
    2
    0
    2
    3
    2
    3
    5
    1
    3
    2
    1
    3
    4
    2
    2
    4
    4
    2
    2
    0
    5
    My point re: analysis... you shed no light in terms of the level of granularity - analyse rows separately / analyse all rows simultaneously (per my example)

    If you want a prompt answer it's generally a good idea to post expected results based on sample data - this way people can see

    a) where you want the results

    b) the logic behind calculating the results
    You also have yet to confirm which version you will be using this with - that will directly impact the possible solutions.

  8. #8
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,772

    Re: COUNTIF to determine "Transitions"

    Does this do what you want (and my apology if it duplicates DO's suggestion).

    EDIT: Looking at DO's last post, I expect it does.
    Attached Files Attached Files
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: COUNTIF to determine "Transitions"

    I just put together the below which uses XL2007 specific approaches (as an alternative to above)

    edit: @shg, not really, I originally suggested a set of 12 to process all rows simultaneously - I suspect OP wants row by row which is what both of our attachments demo.
    Attached Files Attached Files
    Last edited by DonkeyOte; 01-13-2011 at 03:29 PM.

  10. #10
    Registered User
    Join Date
    05-18-2010
    Location
    Zurich
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: COUNTIF to determine "Transitions"

    ok thanks for the help, sorry my previous post was directed to zbors question. and yes I even made a mistake in the example.

    I'll have a look at your solutions, btw. I use excel2010 now if that makes any difference.

    edit: oh sorry I was not clear about that, in fact I want it over all rows averaged, but thats one last step I can do on my own.

  11. #11
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: COUNTIF to determine "Transitions"

    Quote Originally Posted by lexluthor View Post
    edit: oh sorry I was not clear about that, in fact I want it over all rows averaged, but thats one last step I can do on my own.
    this was the approach covered in post # 5

  12. #12
    Registered User
    Join Date
    05-18-2010
    Location
    Zurich
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: COUNTIF to determine "Transitions"

    omg, I just found a huge flaw in my thinking...

    the transition probabilities should of course not be the percentage of all 12 cases, but rather 1.1/ (1.1+1.2+1.3+1.4),i.e., just from the 4 possible paths that it can go from state 1, etc.

    anyway, your solutions are still very useful, a minor change in the code is needed,
    in post #9 it needs to be changed for example into:
    =IF($CA3="";CB2/SUM($CB2:$CE2);COUNTIFS($B3:$BY3;INT(CB$1);$C3:$BZ3;RIGHT(CB$1)))


    ,thanks for the help
    Last edited by lexluthor; 01-14-2011 at 09:25 AM.

  13. #13
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: COUNTIF to determine "Transitions"

    If I've understood - see attached (v2)
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0