How to work with the Boolean field in Google Data Studio (Looker Studio)

Note: Google Data Studio is now known as Looker Studio.

If a data field in your data source can have only one of the two possible values: true or false then you should use the Boolean field while setting up your data source schema.

For example, consider the following Google Sheets data source:

google data studio boolean data type Google Sheets data source

Here the field ‘Is Revenue > Forecasted Revenue’ can have only two possible values: TRUE or FALSE.

For Google Sheets, the values TRUE and FALSE are of type boolean. 

So, when setting up the data source schema, we should set the data type of the field ‘Is Revenue > Forecasted Revenue’ to ‘Boolean’:

Revenue schema 1

This seems pretty straightforward, doesn’t it?

But here is the thing. 

This is not going to work. 

When you create a report from this data source schema which uses the  ‘Is Revenue > Forecasted Revenue field, you will get a system error:

Boolean error

That happened because Looker Studio did not recognize the boolean values stored in Google Sheets as a boolean value. Instead, it treats these boolean fields as ‘text’ fields:

boolean table

No matter how you store boolean values in Google Sheets (whether as true/false, TRUE/FALSE, 0/1, yes/no), Looker Studio won’t recognize them as boolean values.

So, if you want to use a boolean field in Looker Studio then you would need to create and use a calculated metric. 

Follow the steps below:

Step-1: Navigate to your data source schema editor and then change the data type of the field ‘Is Revenue > Forecasted Revenue’ from boolean to text:

convert boolean to text 1

Step-2: At the top right-hand side of your data source schema editor, find and click on the ‘ADD A FIELD’ button to create a new calculated field:

Add a field

Step-3: Enter the name of your new calculated field. For example: ‘[NEW] Is Revenue > Forecasted Revenue’:

add field name 1

Step-4: Type the following text in the ‘Formula’ field: 

case when

followed by a white space:

case when 1

Step-5: Hover your mouse over the field ‘Is Revenue > Forecasted Revenue’ then click on the + button:

hower over dimension 1

After clicking on the + button, your formula field would look something like the one below:

add dimension in formula 1

Step-6: Enter a white space and then type the following text in your formula field:

= “TRUE” then true else false end

unformatted formula 1

Make sure you see the green-colored checkmark at the bottom of the formula box.

google data studio boolean data type green colored checkmark

This checkmark indicates that you have entered the formula correctly. 

If the formula that you have entered is not correct then you will see this symbol   instead of the green checkmark.

google data studio boolean data type red icon

I entered the following formula:

case when Is Revenue > Forecasted Revenue = “TRUE” then true else false end

This means if the value of the field ‘Is Revenue > Forecasted Revenue’ is ‘TRUE’ then return true.  

Otherwise, return false.

The following formula won’t work:

highlighted formula 1

In Looker Studio, you can compare a dimension or metric only with a literal value. 

Here we are comparing the ‘Revenue’ dimension with another dimension called ‘Forecasted Revenue’ via the logical expression: Revenue > Forecasted Revenue 

Step-7: Click on the ‘FORMAT FORMULA‘ button to make your formula more readable:

Format formula 2

After clicking on the ‘FORMAT FORMULA‘ button your formula would look like the one below:

formatted formula 3

Step-8: Click on the ‘Save’ button.

Step-9: Now click on ‘All Fields’ in order to navigate back to the data source schema editor:

All fields 3

You should now see the new calculated field, listed in your data source schema:

new field 1

Note: All calculated fields have got this ‘fx’ symbol through which you can easily spot them.

Now when you create a report based on this data source schema which uses the new calculated field, it would look like the one below:

boolean report table

Following is a short video that shows how I created the calculated field and then used it in my report:

  1. Looker Studio Alternative – Whatagraph
  2. Looker Studio Parameters explained with examples
  3. Looker Studio Number Formats / Data Types
  4. How to Change Language in Looker Studio
  5. Looker Studio Date Format and Time Explained
  6. Looker Studio Tutorial with FREE PDF ebook
  7. Looker Studio Functions, Formulas Tutorial
  8. Looker Studio Page Navigation Tutorial
  9. Understanding Report Editor in Looker Studio
  10. Best practices for creating a report in Looker Studio
  11. How to share reports in Looker Studio
  12. Seven methods to create a new report in Looker Studio
  13. Looker Studio Report Tutorial
  14. How to invite people to view or edit a report in Looker Studio
  15. How to share the link of your report in Looker Studio
  16. Schedule email delivery of a report in Looker Studio
  17. How to download Looker Studio report as PDF
  18. How to embed a Looker Studio report on a website
  19. Guide to Data Types in Looker Studio
  20. Image function in Looker Studio
  21. Image Link data type in Looker Studio
  22. Image data type in Looker Studio
  23. Looker Studio Geo Map – Latitude Longitude
  24. Why You Should Avoid Using Functions and Calculated Fields in Looker Studio
  25. Looker Studio Calculated Fields Tutorial
  26. Working with the Text data type in Looker Studio
  27. The Data Set Configuration Error in Looker Studio
  28. Data Source Fields in Looker Studio – Tutorial
  29. Refresh data source schema fields in Looker Studio
  30. Looker Studio Data Sources – Tutorial
  31. Looker Studio Dimension vs Metric
  32. How to filter by email in Looker Studio
  33. Looker Studio – Sharing Data Sources (aka data source schema)
  34. Field editing in reports – Looker Studio
  35. Data Source Version History in Looker Studio
  36. Community Visualization Access in Looker Studio
  37. Understanding Data Source Credentials in Looker Studio
  38. Understanding Data Freshness in Looker Studio
  39. How to create and configure a data source in Looker Studio
  40. Looker Studio Aggregation Explained
  41. How to Edit a Calculated Field in Looker Studio
  42. Formula Rejection in Looker Studio
  43. Doing Basic Maths on Numeric Fields via Calculated Fields

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade