Solved

Modifying if statement in Excel

Posted on 2015-01-07
8
58 Views
Last Modified: 2015-01-20
Experts,

I have an if statement throughout a spreadsheet which only caculates the value if it is the month is less than the current month.  It worked fine, until I tried to calculate December which is greater than January.  I had not included year in the "if statement".

This is my statement,  
=IF( MONTH(1&"-"&E$7) <  MONTH(TODAY()),SUMIFS(MCLAIMS,MMONTH,MONTH(1&"-"&E$7),MEDIT,$C9),0)

Can someone tell me the best way to modify this statement so it will work all year, including December
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 23

Expert Comment

by:NBVC
ID: 40535944
What does this part:

MONTH(1&"-"&E$7)

supposed to evaluate too?

what do you have in E7?
0
 

Author Comment

by:morinia
ID: 40535976
Sorry,  E7 has "JAN"   G7 = "FEB"   I7 = "MAR"   K7 = "APR"   ........
Bascially it just allows the same formula to be used throughout the columns.  When the formula is copied from one column to the next it works.

The part of the statement that needs adjusting is, I need to add an "OR" to the if

That code was given by an "expert"  a while back.

I am starting to try it myself, I have to test I came up with this so far


=IF(OR( MONTH(1&"-"&E$7) <  MONTH(TODAY(), MONTH(TODAY() - 1 = 0) ),SUMIFS(MCLAIMS,MMONTH,MONTH(1&"-"&E$7),MEDIT,$C9),0)
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40536011
I suspect it would be easier to compare whole dates rather than just months. Dates can be rounded up to the end of the month using EOMONTH function. I will take another look when back at PC.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Assisted Solution

by:NBVC
NBVC earned 250 total points
ID: 40536016
Do you mean to use?

=IF(OR( MONTH(1&"-"&E$7) < MONTH(TODAY()), MONTH(TODAY()) - 1 = 0),SUMIFS(MCLAIMS,MMONTH,MONTH(1&"-"&E$7),MEDIT,$C9),0)

or perhaps, including the year...

=IF(DATE(YEAR(TODAY()-1),MONTH(1&"-"&E$7),1) <DATE(YEAR(TODAY()),MONTH(TODAY()),1),SUMIFS(MCLAIMS,MMONTH,DATE(YEAR(TODAY()-1),MONTH(1&"-"&E$7),1),MEDIT,$C9),0)
0
 

Author Comment

by:morinia
ID: 40536078
Experts,

I was able to get it to work with this formula:

=IF(OR( MONTH(1&"-"&E$7) <  MONTH(TODAY()),MONTH(TODAY()=1)),SUMIFS(MCLAIMS,MMONTH,MONTH(1&"-"&E$7),MEDIT,$C9),0)

This will get me through December.   I hope it works in February for January.
0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 250 total points
ID: 40537562
Are you able to upload a sample file so I can look at comparing whole date option?

Thanks
Rob H
0
 

Assisted Solution

by:morinia
morinia earned 0 total points
ID: 40540376
Rob,

I cannot upload the spreadsheet as is because of the nature of the data.  However, I did add another column in the data and extracted year. I created a named field YYEAR

I entered a formula and Excel modified it slightly so this is what worked using year.  

=IF(OR(MONTH(1&"-"&G$7)<MONTH(TODAY()),YYEAR*(YEAR(TODAY()))),SUMIFS(MCLAIMS,MMONTH,MONTH(1&"-"&G$7),MEDIT,$C9),0)

I will try to create a sample file for you,  as time allows.
0
 

Author Closing Comment

by:morinia
ID: 40559330
I had to make a slight modification to make it work.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question