0

This is the formula, I created to check number of days

IF(({!$Record.Days_Counter__c} => 7  &&   {!$Record.Days_Counter__c} < 14), "Week 1", 
IF(({!$Record.Days_Counter__c} => 14 &&  {!$Record.Days_Counter__c} < 21), "Week 2",
IF(({!$Record.Days_Counter__c} => 21 &&  {!$Record.Days_Counter__c} < 28), "Week 3", 
IF(({!$Record.Days_Counter__c} => 28 &&  {!$Record.Days_Counter__c} < 35), "Week 4", 
IF(({!$Record.Days_Counter__c} => 35 &&  {!$Record.Days_Counter__c} < 42), "Week 5", 
IF(({!$Record.Days_Counter__c} => 42 &&  {!$Record.Days_Counter__c} < 49), "Week 6", 
IF(({!$Record.Days_Counter__c} => 49 &&  {!$Record.Days_Counter__c} < 56), "Week 7", 
IF(({!$Record.Days_Counter__c} => 56 &&  {!$Record.Days_Counter__c} < 63), "Week 8", "Unqualified"))))))))

I still receiving error for Missing ')'. Please anyone locate error.

3 Answers 3

3

Your formula was short of one additional parenthesis at the very end.

Edit: Also, "greater or equal" is >=, not =>.

I could suggest you use some code editor like VS Code that highlights parentheses - it's much easier to write a formula there and then paste it to Salesforce than to write it directly in the formula editor.

Also, it's a little easier to read if you reformat it, here's how would I approach it:

IF(
    ({!$Record.Days_Counter__c} >= 7 && {!$Record.Days_Counter__c} < 14),
    "Week 1", 
    IF(
        ({!$Record.Days_Counter__c} >= 14 && {!$Record.Days_Counter__c} < 21),
        "Week 2",
        IF(
            ({!$Record.Days_Counter__c} >= 21 && {!$Record.Days_Counter__c} < 28),
            "Week 3",
            IF(
                ({!$Record.Days_Counter__c} >= 28 && {!$Record.Days_Counter__c} < 35),
                "Week 4", 
                IF(
                    ({!$Record.Days_Counter__c} >= 35 && {!$Record.Days_Counter__c} < 42),
                    "Week 5",
                    IF(
                        ({!$Record.Days_Counter__c} >= 42 && {!$Record.Days_Counter__c} < 49),
                        "Week 6",
                        IF(
                            ({!$Record.Days_Counter__c} >= 49 && {!$Record.Days_Counter__c} < 56),
                            "Week 7",
                            IF(
                                ({!$Record.Days_Counter__c} >= 56 && {!$Record.Days_Counter__c} < 63),
                                "Week 8",
                                "Unqualified"
                            )
                        )
                    )
                )
            )
        )
    )
)
3
  • Hi @przemyslaw, thank you for your prompt response. I'll follow your advice. But I'm still facing same error.
    – Sehrish
    Commented Apr 29, 2022 at 7:47
  • @Sehrish Ooops, my bad! There was another problem with your formula. Instead of =>, you should use >=, as this is a proper form of the "greater or equal" operator. I updated my answer. Commented Apr 29, 2022 at 9:00
  • 1
    Thanks. It solved my problem :)
    – Sehrish
    Commented Apr 29, 2022 at 15:53
1

Try with below formula.

IF((Days_Counter__c >= 7 && Days_Counter__c < 14), "Week 1",
  IF((Days_Counter__c >= 14 && Days_Counter__c < 21), "Week 2",
   IF((Days_Counter__c >= 21 && Days_Counter__c < 28), "Week 3",
    IF((Days_Counter__c >= 28 && Days_Counter__c < 35), "Week 4",
      IF((Days_Counter__c >= 35 && Days_Counter__c < 42), "Week 5",
        IF((Days_Counter__c >= 42 && Days_Counter__c < 49), "Week 6",
            IF((Days_Counter__c >= 49 && Days_Counter__c < 56), "Week 7",
               IF((Days_Counter__c >= 56 && Days_Counter__c < 63), "Week 8", "Unqualified"))))))))

Note: You should not use => operator, you need to use >=

1
  • Thank you for your answer.
    – Sehrish
    Commented Apr 29, 2022 at 15:52
0

The notes on formatting and using the appropriate operator aside...
Generally speaking, the less we type, the less the chance that we make a mistake.

This formula could easily be simplified if you take the time to apply just a little bit of basic math.

IF(
    OR({!$Record.Days_Counter__c} < 7, {!$Record.Days_Counter__c} >= 63),
    'Unqualified',
    /* The "&" operator concatenates 2 pieces of text */
    /* FLOOR() takes something like "6.28" and rounds down to "6" */
    'Week ' & TEXT(FLOOR({!$Record.Days_Counter__c} / 7))
)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .