+ Reply to Thread
Results 1 to 20 of 20

Sumproduct formula to trade the Week

  1. #1
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Sumproduct formula to trade the Week

    Hi-

    Below formula works for the Month (G$7) references the today () formula, which happens to be 3/24/14 today. If I change Month, to Week it doesn't work. I want to try and track my data for the Week to date. So, this week I would expect it to track 3/24/14 through 3/28/14 when I open the sheet on Friday.

    Please Login or Register  to view this content.
    Thanks

  2. #2
    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: Sumproduct formula to trade the Week

    What values do you have in 'EZE Comp P&L'!$Q$2:$Q$393?
    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

  3. #3
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    It is the date of the file I import everyday. So, when I import today it will come in as 3/24/14

  4. #4
    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: Sumproduct formula to trade the Week

    OK then you need to think about what those 2 parts of the formula are giving you. If you have 3/24/14 in a cell, that is actually 41722 - the number of days elapsed since 1/1/1900, and in another cell, you have weeknum("date") that will give you 13.

    Maybe consider adding a helper column to extract the weeknum from the date, then use that in the calc?

  5. #5
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    I do not want to add a helper column. My formula works for the Month, I am sure there is something out there similar for Week

  6. #6
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    I think replacing Month with Weeknum(g7) will work?

  7. #7
    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: Sumproduct formula to trade the Week

    upload a sample workbook, im not going to guess

  8. #8
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    test2.xlsx.xlsmSee attached. Thanks

  9. #9
    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: Sumproduct formula to trade the Week

    hmm seems weeknum() does not work that way the same as month() does. Let me ask the others

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct formula to trade the Week

    If testing a range of dates for WEEKNUM you have to coerce the range of dates into an array:

    =SUMPRODUCT(--(WEEKNUM(A1:A10+0)>25))

    This will not work in Excel versions 2003 and earlier.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  11. #11
    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: Sumproduct formula to trade the Week

    OK so what am I missing here, Tony?

    =(SUMPRODUCT((--WEEKNUM('EZE Comp P&L'!$Q$2:$Q$5000)=WEEKNUM(B$7))*('EZE Comp P&L'!$B$2:$B$5000="pHILLIPINES")*('EZE Comp P&L'!$O$2:$O$5000)))/1000000

    Q contains real dates, B7 contains TODAY()

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct formula to trade the Week

    Assuming the formula is otherwise correct:

    =(SUMPRODUCT(--(WEEKNUM('EZE Comp P&L'!$Q$2:$Q$5000+0)=WEEKNUM(B$7))*('EZE Comp P&L'!$B$2:$B$5000="pHILLIPINES")*('EZE Comp P&L'!$O$2:$O$5000)))/1000000

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct formula to trade the Week

    Eh, let's do it like this...

    =SUMPRODUCT(--(WEEKNUM('EZE Comp P&L'!$Q$2:$Q$5000+0)=WEEKNUM(B$7)),--('EZE Comp P&L'!$B$2:$B$5000="pHILLIPINES"),'EZE Comp P&L'!$O$2:$O$5000)/1000000

  14. #14
    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: Sumproduct formula to trade the Week

    That actually worked great Tony, thanks forthe assist...
    =(SUMPRODUCT((--WEEKNUM('EZE Comp P&L'!$Q$2:$Q$5000+0)=WEEKNUM(B$7)-1)*('EZE Comp P&L'!$B$2:$B$5000=$A12)*('EZE Comp P&L'!$O$2:$O$5000)))/1000000

    @ cartica, you have no data in week 13 (todays date), so I added the WEEKNUM(B$7)-1 to get some data to test - remove that for your data

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct formula to trade the Week

    ------

  16. #16
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    any thoughts?

    Thanks

  17. #17
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    sorry, I missed these. I am going through them now. Thanks

  18. #18
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Sumproduct formula to trade the Week

    Thanks guys that worked. A few questions. What does the ((-- in front of Weeknum do?, as well as the +0?

    Thanks

  19. #19
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Sumproduct formula to trade the Week

    Do you ever have data across more than one year? In that situation you might want to avoid using WEEKNUM because 1) you might confuse week n in one year with week n in other years and 2) WEEKNUM always starts on Jan 1st as 1, Dec 31st will be in a different week, as far as WEEKNUM is concerned, even if it's in the same actual week.

    If you have a cell that contains the start date of the week it might be easier to use SUMIFS like this

    =SUMIFS(Sum_range,Date_range,">="&Z2,Date_range,"<"&Z2+7)

    where Z2 contains start date of the week - you can add more conditions to SUMIFS as required
    Audere est facere

  20. #20
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumproduct formula to trade the Week

    Quote Originally Posted by cartica View Post
    What does the ((-- in front of Weeknum do?, as well as the +0?
    For the double unary minus, --, see this:

    http://xldynamic.com/source/xld.SUMPRODUCT.html

    The +0...

    In Excel versions 2003 and earlier, the WEEKNUM function is part of the Analysis ToolPak add-in. Functions in the ATP could not be used to calculate arrays. In Excel 2007 all the functions that were in the ATP from earlier versions were "rolled" into application as built-in functions. In other words, the ATP add-in was no longer needed to use some functions including the WEEKNUM function.

    The old ATP functions can now calculate arrays BUT you have to force the array calculation. One way to do that is to add 0 to each numeric element of the array (range).

+ 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: 2
    Last Post: 09-08-2012, 10:51 AM
  2. Replies: 11
    Last Post: 04-06-2011, 02:33 PM
  3. SUMPRODUCT to count by week
    By sanlen in forum Excel General
    Replies: 13
    Last Post: 06-16-2010, 01:40 AM
  4. Sumproduct by time & day of week
    By Henry c in forum Excel General
    Replies: 8
    Last Post: 01-22-2010, 03:36 PM
  5. [SOLVED] Sumproduct-week number
    By John997 in forum Excel General
    Replies: 1
    Last Post: 09-29-2005, 10:52 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