Chat with us, powered by LiveChat

Get a quick quote with our pricing calculator

Knowledge Base

Browse our knowledge base articles to quickly solve your issue.

Knowledgebase articles

Introduction to the IF Statement

This post is to help you become more familiar with the IF statement within a Report, it will cover how it can be used in a Reporting. IF statements are a great way to see if a statement is true or false and output accordingly.

The structure of an IF statement is as follows:

IF(statement, TrueValue, FalseValue)

Where the statement is the condition we are testing, the TrueValue is the output if the statement is true and the FalseValue is output when the statement false.

Examples of IF Statements

Example 1

If an Organisation’s Industry is ‘Manufacturing’ or ‘Education’ output ‘Team 1’ otherwise output ‘Team 2’ 

So for this example the IF statement breaks down into the following:

Statement:industry = 'manufacturing' OR industry = 'Education'
TrueValue: 'Team 1'
FalseValue: 'Team 2'

So your Calculated Column will look like the following:

IF(industry = 'manufacturing' OR industry = 'Education’, 'Team 1', 'Team 2')

pasted-image-0-24_0.png

If you are specifying two criteria in an IF statement you need to define the column each time, even if it is the same.

Example 2

If a Case has a priority of High and the Case status is new output ‘High Priority’ otherwise ‘low priority’

So this time the IF statement will breakdown as the following:

Statement: priority_name = '(2) High' AND  status_name = 'New'
TrueValue = ‘High Priority’
FalseValue = ‘Low Priority’

So your Calculated Column in the Report will be:

IF( priority_name = '(2) High' AND status_name = 'New', 'High Priority', 'Low Priority')

pasted-image-0-25.png

Example 3

IF statements are also incredibly useful for the creation of Summary Views, especially when you want to see how many Records satisfy the IF statement in the Report.

For example if you want to count how many People in the database have either a blank Job Title or Job Role.

In this case your IF statement will breakdown as follows:

Statement = person_job_role = '' OR  person_job_title = ''
TrueValue = 1
False Value = 0

So that the IF statement will look like:

IF(person_job_role = '' OR person_job_title = '',1,0)

The above statement will be the one that is actually used in Workbooks.

pasted-image-0-26.png

Now you can create a Summary View with a subtotal column to see how many People in the database there are with a blank Job Role or Job Title.

ifstatement.png