+ Reply to Thread
Results 1 to 7 of 7

making a "if" function that uses only the month/year values from a date

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    6

    making a "if" function that uses only the month/year values from a date

    Hello

    I am working on making a 4 column list into a tabel. Essentially, the columns are date, item, debit and kredit. What I want to do is to sort the items into a table where each item is listed along with debit/kredit value, as a function of month/year. In other words, my new table should contain rows that represent the item and columns that represent the month and the year.

    I figure I can do this with an if function, something along the lines of =IF(AND(H4=C4;I$2=B4);D4:E4;""), but I cannot work out how to make excel use only the month/year value from my date value. In other words, I have a date value like this:

    08-09-2011

    but the date itself is irrelevant to me, I want the formula only to look at the month and the year.

    Any help would be appreciated.

    Thank!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: making a "if" function that uses only the month/year values from a date

    It would be helpful if you posted some sample data. There are excel functions that return only the month or year.

    Look here
    http://www.techonthenet.com/excel/formulas/month.php

    http://www.techonthenet.com/excel/formulas/year.php
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: making a "if" function that uses only the month/year values from a date

    Hi

    =MONTH(A1), gives the month of the date in A1

    =YEAR(A1), gives the year of the date in A1
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    10-01-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: making a "if" function that uses only the month/year values from a date

    I'm not sure if I understand what you are asking for, but try
    - right click --> format cells
    - then pick date from the category list, and simply chose the format you like.

    Is this what you meant?

  5. #5
    Registered User
    Join Date
    10-01-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: making a "if" function that uses only the month/year values from a date

    Thank you very much for the help.

    So far I've managed to come up with this:

    =IF(AND($H4=$C4;MONTH($B4)=MONTH(I$2);YEAR($B4)=YEAR(I$2));AVERAGE($D4:$E4);"")

    However,

    My data roughly looks like this:

    Date Item Debit Kredit
    08-10-2010 A -310,00
    09-11-2010 A -310,00
    10-12-2010 B 230,00
    07-01-2011 C -253,00
    05-02-2011 C -253,00

    etc. I'd like to combine it into a table that looks something like this:
    .........10-2010..........11-2010.........12-2010.........01-2011.........02-2011
    A........-310,00..........-310,00
    B..................................................230,00
    C....................................................................-253,00.........-253,00

    Hope it makes sense.

    Thanks
    Last edited by ATraveller; 10-01-2012 at 10:50 AM.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: making a "if" function that uses only the month/year values from a date

    It would be easier for all of us, if you'll upload a small sample workbook.

  7. #7
    Registered User
    Join Date
    10-01-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: making a "if" function that uses only the month/year values from a date

    I think my problem now is somewhat different, so I'll make a new thread for it. This one is solved, thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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