Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 5
Default sum columns only if date

Hi, I need a little help with this function.

I have dates in column A (3/31/12), an categories in column B (maintenance) and then a dollar amount in column C ($52.55).

I would like a function that would sum the dollar amounts only if the date was in March and the catagory matched "maintnenance"

Any help?

Thanks,

David

Last edited by dkte737 : June 10th 12 at 02:43 PM
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 587
Default sum columns only if date

hi David,

=SUMPRODUCT(--(MONTH($A$2:$A$100)=3)*($B$2:$B$100="maintnenance" )*($C$2:$C$100))


--
isabelle



Le 2012-06-10 09:39, dkte737 a écrit :
Hi, I need a little help with this function.

I have dates in column A (3/31/12), an categories in column B
(maintenance) and then a dollar amount in column C ($52.55).

I would like a function that would sum the dollar amounts only if the
date was in March and the catagory matched "maintnenance"

Any help?

Thanks,

David




  #3   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by dkte737 View Post
Hi, I need a little help with this function.

I have dates in column A (3/31/12), an categories in column B (maintenance) and then a dollar amount in column C ($52.55).

I would like a function that would sum the dollar amounts only if the date was in March and the catagory matched "maintnenance"

Any help?

Thanks,

David
Hi,

Which version of Excel are you using?
  #4   Report Post  
Junior Member
 
Posts: 5
Default

Quote:
Originally Posted by Spencer101 View Post
Hi,

Which version of Excel are you using?
Office 2010

thanks,

David
  #5   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by dkte737 View Post
Office 2010

thanks,

David

I've used SUMPRODUCT in the attached. It can also be done with SUMIFS but it's far less easy to read.

Hope it makes sense. Feel free to clarify if not.
Attached Files
File Type: zip Example1.zip (5.9 KB, 50 views)


  #6   Report Post  
Junior Member
 
Posts: 5
Default

Quote:
Originally Posted by Spencer101 View Post
I've used SUMPRODUCT in the attached. It can also be done with SUMIFS but it's far less easy to read.

Hope it makes sense. Feel free to clarify if not.
That worked! Ok, simple question....how did you get your top row (DATE) to not move when you sort oldest to newest?

David
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default sum columns only if date

"isabelle" wrote:
=SUMPRODUCT(--(MONTH($A$2:$A$100)=3)*($B$2:$B$100="maintnenance" )*($C$2:$C$100))


@Isabelle....

There is no need for the double negative (--) in this context.

The purpose of the double negative in the
expression --(MONTH($A$2:$A$100)=3) is to convert TRUE and FALSE (the result
of the comparison) to 1 and 0 which is required for SUMPRODUCT to work as
intended.

But __any__ arithmetic will perform that conversion. So the expression
(MONTH($A$2:$A$100)=3)*($B$2:$B$100="maintnenance" ) is sufficient to "and"
the two conditions and produce 1 or 0. No double negative is needed.

@David: We cannot write simply
AND(MONTH($A$2:$A$100)=3,$B$2:$B$100="maintnenance ") in the context of
SUMPRODUCT because AND will process the entire arrays and produce a single
value instead of an array which is required for SUMPRODUCT to work as
intended.

There is nothing wrong (otherwise) with the SUMPRODUCT expression above.
However, the following is arguably more flexible and it is more efficient
when C2:C100 is expected to contain numeric values, as David stated:

=SUMPRODUCT((MONTH($A$2:$A$100)=3)*($B$2:$B$100="m aintnenance"),$C$2:$C$100)

If some of C2:C100 might contain non-numeric values (notably the null
string, ""), SUMPRODUCT treats them as zero, whereas SUMPRODUCT(...*C2:C100)
will result in an Excel error.

It is not uncommon to encounter null strings among columns of numbers in
templates, for example.

  #8   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by dkte737 View Post
That worked! Ok, simple question....how did you get your top row (DATE) to not move when you sort oldest to newest?

David
I didn't. I typed it in that way. BUT, make sure each used column has a header and making sure they're distinguishable from regular data (i.e. make them bold) usually helps.

Failing that, highlight the data and use the sort menu option rather than just the A-Z or Z-A button. In there will be an option that says "My data has headers" or something similar. Either unselect or select it depending on your need.
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default sum columns only if date

<FWIW
In my personal bookkeeping app I use 'FiscalPeriod' columns to the
right of (Income/Expense) transaction details, one column for each
month of the fiscal year. The row above the month labels containing
their respective indexes (ie:Jan=1,Feb=2...). To capture transaction
amounts into their respective month columns I use the following
formula...

=IF(OR(Date="",MONTH(Date)<MonthIndex),"",IF(Curr encyType<"",Amount*ExchRate,Amount))

...which leaves empty cells blank for a cleaner look to the section (I
hate looking at zeros when not needed). You could modify it for your
needs by implementing the month indexes concept without the defined
names as long as the correct col/row abs/rel refs are used. *Note* that
all names have local scope (sheet-level) because they are duplicated on
both the Income ledger sheet and the Expenses ledger sheet.

'Date' is a col-absolute/row-relative dynamic defined name range for
entering the transaction date.

'MonthIndex' is a col-relative/row-absolute defined name that specifies
the where the month indexes are stored. (This is hidden by matching
font color to fill color)

'CurrencyType' is a col-absolute/row-relative defined name used for
'flagging' foreign currency amounts via a DV dropdown. To the right is
('ExchRate') where the foreign currency exchange rate is entered.

'Amount' is a col-absolute/row-relative defined name used for the
transaction 'items' total (excluding taxes). (Transactions may use
multiple records (each row is a 'transaction record') if the items are
spread over more than one accounting 'Category' or 'Subcategory')

For maintenance simplicity, the above formula is stored in a defined
name ("PeriodAmount") so I only need to make changes in one place (per
sheet where defined/used). In this case, the formula entry for all
cells in the fiscal period section is...

=PeriodAmount

To use the formula without defined names...

=IF(OR($B6="",MONTH($B6)<Q$4),"",IF($H6<"",$J6*$ I6,$I6))

...where the first transaction starts in row 6, month indexes are in row
4, and the fiscal period section starts in col "Q". You could copy it
down and across OR preselect the entire area and use the keyboard combo
'Ctrl+Enter' to populate all selected cells. (I use a 'BlankRecord'
[hidden row] for inserting more rows where/when needed, and so the 12
formulas are already in place)

IMO, using defined names makes things easier to understand. (I just
hate having to trace refs to see what/where they point to when it's so
much easier to use self-describing names)

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 621
Default sum columns only if date

In Sort Options enable "my data range has header row"


Gord

On Sun, 10 Jun 2012 15:48:57 +0000, dkte737
wrote:


Spencer101;1602557 Wrote:
I've used SUMPRODUCT in the attached. It can also be done with SUMIFS
but it's far less easy to read.

Hope it makes sense. Feel free to clarify if not.


That worked! Ok, simple question....how did you get your top row (DATE)
to not move when you sort oldest to newest?

David


+-------------------------------------------------------------------+
+-------------------------------------------------------------------+

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula for determining if two date columns fall within specific date range Igottabeme Excel Worksheet Functions 2 April 21st 06 02:50 AM
Formula for determining if two date columns fall within specific date range Igottabeme Excel Discussion (Misc queries) 1 April 20th 06 10:03 PM
formula to look up a date and add x, y, z columns to x, y, z row Sally J Excel Worksheet Functions 1 December 7th 05 03:08 AM
excel formula counting date to date in 4 columns stuie d Excel Worksheet Functions 1 May 4th 05 12:46 PM
DATE SORT BY COLUMNS Sue Excel Worksheet Functions 0 January 13th 05 06:03 AM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"