Trying and Failing to use nested IF Statement in MS Word

  • 24 June 2021
  • 9 replies
  • 440 views

I've done plenty of IF statement formulas in Word, and plenty of NESTED IF statement in Salesforce, but I can't seem to get a nested IF statement to work in Word. I've looked many Google results and the approaches never quite work, I'm assuming I'm down to something as simple as a misplaced quotation mark now.

My use case is to TRANSLATE an English pick value into German for the output document. The users aren't using German, but the customers might be. I've tried a dozen variables of the statement below, but the output keeps resulting as {IF regardless of input. It's treating the very first statement as a false instead of moving to the next nest... Can anyone recommend a fix?

 

IF "<<Quote_to_Contract_Commitment_Level>>" = "Quarterly" "Vierteljährlich" {IF "<<Quote_to_Contract_Commitment_Level>>" = "Monthly" "Monatlich" {IF "<<Quote_to_Contract_Commitment_Level>>" = "Other" "Andere" "Jährlich" } }


9 replies

Userlevel 3
Badge +12

Hi,


Are you missing any delimeter in the syntax? I have updated it with "," please check if it works.


IF "<<Quote_to_Contract_Commitment_Level>>" = "Quarterly" "Vierteljährlich",
  {IF "<<Quote_to_Contract_Commitment_Level>>" = "Monthly" "Monatlich",
    {IF "<<Quote_to_Contract_Commitment_Level>>" = "Other" "Andere" "Jährlich" }
}

That didn't work unfortunately, now it treats the comma as the fallback word. It would have surprised me, of the many examples I've looked at, none utilize comma delimiters in Word. Only spaces.


 


Before and after merge posted below.


Hi @chrishigh 


 


You may try in this format instead of nested


 


{IF "<<Quote_to_Contract_Commitment_Level>>" = "Quarterly" "Vierteljährlich"  ""}


{IF "<<Quote_to_Contract_Commitment_Level>>" = "Monthly" "Monatlich"  ""}


{IF "<<Quote_to_Contract_Commitment_Level>>" = "Other" "Andere" "Jährlich" } 


 


Regards


S.Aj

Userlevel 5
Badge +13

@chrishigh When nesting it usually is in the false condition and should like this format. A third nest would replace the last tag location.


{IF "<<tag>>" = "Retainer" "True" "{IF "<<tag>>" = "Sample" "" "<<tag>>"}"}

I tried that format before, unfortunately it's one of the versions that just puts {IF into the document. It's treating the quote mark before the bracket and the one before the tag as the container of a text phrase instead of obeying the rest of the formula. Here's exactly what I used:

{IF "<<Quote_to_Contract_Commitment_Level>>" = "Quarterly" "Vierteljährlich" "{IF "<<Quote_to_Contract_Commitment_Level>>" = "Monthly" "Monatlich" "{IF "<<Quote_to_Contract_Commitment_Level>>" = "Other" "Andere" "Jährlich"}"}"}
Userlevel 5
Badge +13

@chrishigh  That's odd that usually works for me, are you inserting the new conditional text inside rather than copy pasting?

Not sure what you mean, what I've pasted above is exactly as it appears in the Formula builder of Word (except for the very first and vary last brackets which self-populate when the formula is saved and field visibility is toggled, I included them for illustrative purpose).


 


@Safiya your method is cheating LOL. 😆 But, it does work as long as I use FOUR unique statements instead of three. By including the false statement in your last formula, you cause Jährlich to appear under every circumstance, including combined with the other two values when summoned. Here's the working set:


 



 


There is one unseen benefit to using this method - Word is rather restrictive about the length of formulas you can build, and this does get around that.

Userlevel 5
Badge +13

@chrishigh I usually do my formulas using ctrl+f9 to insert the new conditional text rather than the formula builder, that's what I meant by inserting.

Ah, since Word is so finicky and with so little space in the formula builder to word, I usually insert the Field (from quick parts) and paste in a complete formula (with no line breaks) that I've assembled in Text or Notepad++

Reply