function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adam BurnAdam Burn 

Formula "IF AND within past year, display conditional images"

I'm trying to display a graphic that is conditional based on whether a certain number of events have occured during the past calendar year. The logic is as follows - if someone has attended more than 2 occasions in the past 12 months, display a smiley face. If not, display a frowny face. I can get this to work without the date parameters but I can't figure out how to limit the formula to assessing just the past 12 months from the current day. Any suggestions would be very much appreciated!

Here is what I've got so far:

IF(Total_Occasions_Attended__c >2, TODAY() - Date_of_Last_Participation__c),
IMAGE("/servlet/servlet.FileDownload?file=015f00000005Qgv", "Happy", 16, 16),
IF(Total_Occasions_Attended__c <3,TODAY() - Date_of_Last_Participation__c ),
IMAGE ("/servlet/servlet.FileDownload?file=015f00000005QhP", "Sad", 16, 16),NULL))

I keep getting this error:

Error: Syntax error. Extra ','

Adam BurnAdam Burn
To clarify, Total_Occasions_Attended__c is a rollup summary field and Date_of_Last_Participation__c is a custom date field that is populated by a workflow field update whenever a participant's record has been updated to reflect attendance at an Occasion. I'm just looking for a way to monitor overal event participation graphically. If a participant has attended at least 2 Occasions during the past year, they are in good standing, else, they get the frowny face.
Mike OtterMike Otter
First off, I like the question because it gives me an idea for my own app.  :)

Secondly, the extra comma is because your IF statement is structured incorrectly.  The gist is there but the intended logic isn't.  In the question, you say "if someone has attended more than 2 occasions in the last year".  That should translate into "if total > 2 and their last attendance was within the last year" but your IF statement is actually just checking the number of occasions attended.  Look slowly at the code or break each part of the IF statement into a single line--that should reveal the syntax error.

I'm purposefully being vague because I sense you know what you're doing and I don't want to give you working code if all you need is a little nudge.

Mike