IF

The IF function performs a logic equation based on a preset condition and then returns values based on the result of the equation. The function will either return the value specified in the if true parameter or if false parameter, and displays the result in your Klip.

The syntax for the IF function is:

IF( condition , if true , if false )

Parameters

condition The value you want to test. vector
if true The value returned if the condition evaluates to true. vector
if false The value returned if the condition evaluates to false. vector

Example: using IF to align data

In these examples, we use the data source shown below containing repeating dates and country values that we want to align to create a chart. 

Building the X Axis

Create a Bar/Line Chart component.

Use the dates from your data to make up the X Axis.

Select your dates, in this example column A (A:A), then use the Group option in the Properties panel to group the dates so each date appears as one label. 

Building the Series

Option 1:

Use two Series sub-components to display the sum of survey responses per country. Both Series sub-components use the Country values in column B (B:B) and the Number of Responses in column D (D:D) to create a condition.

"0" is returned for any data that is false in the condition.

Series 1: Canada

IF(SLICE(@B:B)="Canada",SLICE(@D:D),0)

Series 2: USA

IF(SLICE(@B:B)="USA",SLICE(@D:D),0)

Use the Aggregation method, Sum, in both Canada and USA Series to sum the total responses per country for each date. The data is correctly aligned because the Sum aggregation does not count data with a value of 0.

Option 2:

Use two Series components to display the number of times Canada or USA responded to the survey per date. Both Series sub-components use the Country values in column B (B:B)  and a value of "1" per Country.

BLANK is returned for any data that is false in the condition. 

Series 1: Canada

IF(SLICE(@B:B)="Canada",1,BLANK())

Series 2: USA

IF(SLICE(@B:B)="Canada",1,BLANK())

Use the Aggregation method, Count, in both Canada and USA Series to count the amount of responses for each date. The data is correctly aligned because the Count aggregation does not count BLANK data.  

Learn more: