webi

Nested if statements with conditional operators in SAP WebI


I want to check different conditions and based on each condition a specific action should be triggered.

In the following example, I want to check the request type if it is new OR amendment AND Build Date Completion is not null then I need the days between the dates included in the first parenthesis otherwise I need the days between the dates included in the second parenthesis.

However, when I run the query I could only see the actual formula pasted in each row.

Does anyone know what I am doing wrong?

="If([Build Request Type]=\"New\")
OR
If([Build Request Type]=\"Amendment\") 
AND Not(IsNull([Build Date Completion])
Then
    DaysBetween([Actual build date];[Ordering Tool Validation Complete Date]) 
else 
    DaysBetween([Submission];[Actual build date])"

Solution

  • Here is the correct answer:

    =If(([Build Request Type]="New") OR
      ([Build Request Type]="Amendment")) AND Not(IsNull([Build Date Completion])) Then
        DaysBetween([Actual build date];[Ordering Tool Validation Complete Date])
     Else 
        DaysBetween([Submission];[Actual build date])
    

    First off all you need to remove the double-quotes from around your code. With those double-quotes are you are saying that is exactly what you want to see and that is what you are getting. Next, you need to remove the backslashes before your remaining double-quotes. Finally, you need to make sure you parentheses are in the correct spots to get the logic you want.