Conditional statement based on timeframes
This might be a little confusing to explain so hopefully I can make it clear what I am trying to do. I have a report that shows survey results that clients submit.The report allows users to select a start date and end date. They can only select months as the timeframe, i.e. January2011 - April2011, Fed2011 - Mar-2011, etc. The data that they see is rolled up per month, and all surveys are due in by the 10th. So basically, since it is May, if you want to see April's data, you can run the report but it won't be 100% accurate unless you run it after the 10th of May, because people will still be submitting their surveys. What I originally did was make an expression so that if someone ran the report on any day from the 1st to the 9th of a month, it would throw up a comment saying that the data might not be completely accurate until the 10th. I did that with the following: =IIF(day(now) < 10, "Report may not be indicative of full month if run before the 10th.", " ") The problem that didn't hit me was that, while that will work now if they want to see April's data and run it within the next few days, if they decide they want to see an EARLIER month, it's still going to give them that warning message even though it is not accurate since, if they ran the report for Feb for example, Feb's data was due Mar 10th and has long since been completed. So what I need is to say is basically: If you select a timeframe of last month, and today's date is the 1st-9th of this month, give the warning message. If it's more than 1 month prior to today's date, don't give any warning message. I figure what I already have is somewhat close, but I'm not especially skilled with the expressions yet and thus far have had no luck. I thought maybe SWITCH was the way to go but I can't get it working with the logic I have in my head, which was something like: =Switch(day(now) < 10, "Report may not be indicative of full month if run before the 10th.", month(now) >= 2, " ") Plus I think the month(now) business is the wrong way to go about it, since I probably need to base that off of the StartDate.Value or EndDate.Value Ideas? =) Thanks! Dachish
May 3rd, 2011 7:43pm

Hello if you have not yet solved this try customising this query to meet yours =iif(Month(Parameters!end.Value) = Month(dateadd("M",-1,Now())) and Day(Now())<= 9,"Report may not be accurate",nothing) this checks the end date month is not equal to last month of present time and if it is, is the presnt date <=9 The only but is if if you want to constraint users from picking and end date greater that the present date then you might have to use a nested iif, Let me know if this helps
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2011 12:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics