The IF function is a logical function that will return one value if the condition is "true" and another if it is "false".
This article uses a basic example to explain how to use the IF function. It also includes a video demonstration that uses sample data in your account so you can follow along.
The following Klip uses conditions and three series sub-components to count the number of "Yes" and "No" responses by date and the number of items sold for "Yes" responses . The IF function is used to ensure the count of records remains aligned.
The Klip above uses a data source that looks like this:
Step 1: Build the X Axis
Use the Bar/Line Chart component and a data source to start building your bar chart. The dates from your data will make up the x axis.
Select your dates, in our example column A (A:A
). Next, group the dates (so each date displays as one label) by either selecting the Group Repeating Labels option in the Properties panel or using the GROUP function.
Step 2: Build the Series
Use two Series components to display the survey responses. Both components use formulas with IF and the survey response values in column B (B:B
) (in our example) to create a condition. BLANK is returned for any data that is false in the condition.
Series 1: No
IF(values="No", values, BLANK())
Series 2: Yes
IF(values="Yes", values, BLANK())
Select Count as the Aggregation method in both the "Yes" and "No" Series to count the amount of responses for each date. The data will be correctly aligned because the Count aggregation does not count BLANK data.
Series 3:
Add a third Series component to display the total number of items sold per date. Select the column of data that lists the amount of items sold, in our example column C (C:C
).
Select Sum as the Aggregation method to sum the amount of responses for each date. The data will be correctly aligned because the Sum aggregation does not count BLANK data.
Video demo on using the IF function when building a bar chart
Watch this video for a quick demonstration on how to use the IF function to build a bar chart custom Klip. It uses sample data that’s included in your Klipfolio account so you can follow along.
Please note that after this video was filmed, we improved the method for adding a component and a data source to a custom Klip. After clicking Build a Custom Klip, you land in the Klip Editor where you select the Bar/Line Chart component and drag it into your Klip. Then you connect to your data by clicking +Add Data Source at the bottom of the Klip Editor window.