+ Reply to Thread
Results 1 to 11 of 11

Display 1 or 0 Based on the time a number shows up.

  1. #1
    Registered User
    Join Date
    09-24-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    38

    Display 1 or 0 Based on the time a number shows up.

    I need help on a formula and I'm not sure how to even start. I want to compile a list of all open PO's but the issue I'm running into my data contains several line items from each open PO. So I cannot do a standard sumif based on PO number. I'm thinking the best way is to add a column to the query which will display a 1 for the first time a PO number shows up in the query then a 0 for each subsequent time it shows. Then I can do a sum if base don that column. Does anyone have an idea on the based way to build this formula. I've showing a very condensed version of data below for display purposes.



    1 PO Line Date Val
    2 P36 1 17-Jan
    3 P36 2 17-Feb
    4 P36 3 17-Mar
    5 P36 4 17-Mar
    6 P37 1 17-Feb
    7 P37 2 17-Feb
    8 P38 1 17-Mar
    9 P39 1 17-Mar
    10 P40 1 17-Apr
    11 P41 1 17-Feb
    12 P41 2 17-Jan
    13 P41 3 17-Feb
    14 P41 4 17-Jan

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Display 1 or 0 Based on the time a number shows up.

    So the first date is the date the PO is opened. Is the next date a closure and then the 3rd date is reopened and so forth?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: Display 1 or 0 Based on the time a number shows up.

    Assuming PO's in column A, paste this in D2 and copy down:
    =--(COUNTIF($A$1:$A1,$A2)=0)

    The double-dash is known as a double unary operator. It provides a mathematical operation so Excel shows 1/0 instead of TRUE/FALSE.

    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
    Last edited by leelnich; 05-19-2017 at 10:31 AM.

  4. #4
    Registered User
    Join Date
    09-24-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Display 1 or 0 Based on the time a number shows up.

    Quote Originally Posted by ChemistB View Post
    So the first date is the date the PO is opened. Is the next date a closure and then the 3rd date is reopened and so forth?
    No the PO could last up to a year and have several difference services each with their own line number. The dates are when the services for that line was rendered.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Display 1 or 0 Based on the time a number shows up.

    If you are just looking to count unique PO numbers try

    =SUMPRODUCT(1/COUNTIF($A$2:$A$100))

    Is that what you are after? From your data, there's no way to tell if a PO is open or closed because you don't know how many line items it had on it.

  6. #6
    Registered User
    Join Date
    09-24-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Display 1 or 0 Based on the time a number shows up.

    Quote Originally Posted by leelnich View Post
    Assuming PO's in column A, paste this in D2 and copy down:
    =--(COUNTIF($A$1:$A1,$A2)=0)

    The double-dash is known as a double unary operator. It provides a mathematical operation so Excel shows 1/0 instead of TRUE/FALSE.

    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
    This seems to have worked!

  7. #7
    Registered User
    Join Date
    09-24-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Display 1 or 0 Based on the time a number shows up.

    Quote Originally Posted by ChemistB View Post
    If you are just looking to count unique PO numbers try

    =SUMPRODUCT(1/COUNTIF($A$2:$A$100))

    Is that what you are after? From your data, there's no way to tell if a PO is open or closed because you don't know how many line items it had on it.
    Sorry I should have been more clear. The SQL pulling from the database is set to only pull open PO's. This is a tool to investigate old open PO's.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Display 1 or 0 Based on the time a number shows up.

    Then that formula will count unique PO's. No need for extra columns.

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

    Re: Display 1 or 0 Based on the time a number shows up.

    Hi ChemistB - OP did state:
    ...I want to compile a list of all open PO's...

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Display 1 or 0 Based on the time a number shows up.

    In F2 dragged down

    =LOOKUP(REPT("Z",5),CHOOSE({1;2},"",INDEX($B$2:$B$100,MATCH(TRUE,INDEX(ISNA(MATCH($B$2:$B$100,$F$1:$F1,0)),0),0))))
    Attached Files Attached Files

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

    Re: Display 1 or 0 Based on the time a number shows up.

    Or this ARRAY FORMULA (again, assuming POs in column A):

    =IFERROR(INDEX($A$2:$A$500,MATCH(0,COUNTIF($E$1:$E1,$A$2:$A$500),0)),"")

    Select E2, paste in Formula Bar and then press CTRL+SHIFT+ENTER to confirm array status. Now fill down using the drag handle.

    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
    Last edited by leelnich; 05-19-2017 at 02:09 PM.

+ 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: 4
    Last Post: 01-16-2014, 05:22 PM
  2. Chart which shows number of time values occurs
    By dominion in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-19-2013, 05:36 PM
  3. Replies: 4
    Last Post: 04-12-2013, 01:17 PM
  4. Replies: 2
    Last Post: 12-16-2011, 08:35 PM
  5. Display a message based on time
    By LisaPatch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2011, 10:11 AM
  6. Replies: 5
    Last Post: 08-21-2010, 02:08 PM
  7. Making a Graph that shows Frequency based on time
    By jamboc in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 11-12-2006, 11:38 PM
  8. Display a number as Kilometers and k/hr & as Time
    By Gonzo in forum Excel General
    Replies: 6
    Last Post: 11-25-2005, 05:15 AM

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