Doing Basic Maths on Numeric Fields via Calculated Fields

Do you want expert help in setting up/fixing GA4 and GTM?

If you are not sure whether your GA4 property is setup correctly or you want expert help migrating to GA4 then contact us. We can fix your website tracking issues.

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

Follow the steps below to do basic maths on numeric fields via calculated fields:

Step-1: Consider the following data source named ‘Sales- ABC Inc’:

New data source

This is the data source, we are going to use.

Step-2: Navigate to Looker Studio and then click on the ‘Create’ button:

create report button 1

Step-3: Click on ‘Data Source’:

Data sources 3

Step-4: Click on the ‘Google Sheets’ connector as we are going to use Google Sheets document as our data source:

connector select 2

Step-5: Find and click on your Google sheets document:

Find and click on your Google sheets document

Step-6: Click on the ‘Connect’ button on the top right-hand side to connect your data source to data source schema:

connect button data studio

The data source schema for this data source would look like the one below:

new data source schema

Step-7: Correct the data types of various fields by changing them from their corresponding drop-down menus:

correct data type

Step-8: Click on the ‘Add a field’ button:

Add a field google data studio

Step-9: Name the new calculated field: Ecommerce Conversion rate:

Name the new calculated field

Step-10: Hover your mouse over the ‘Total Transactions’ field:

Hover your mouse over the Total Transactions field

Step-11: Click on the ‘+’ button next to it:

plus button

Once you clicked on the + button, the ‘Total Transactions’ field would appear in the formula box:

Total Transactions field

Step-12: Press the spacebar key on your keyboard to give one white space.

Step-13: Type forward slash ‘/’ from your keyboard and then give another white space by pressing the spacebar key:

Type forward slash

Step-14: Hover your mouse over the ‘Total Website Sessions’ field and then click on the ‘+’ button next to it:

Total Website Sessions field

The final formula to calculate the ecommerce conversion rate is going to look like the one below:

The final formula to calculate the ecommerce conversion rate

Here we are using the arithmetic operator ‘division’ denoted by a forward slash / between the two numeric fields: ‘Total Transactions’ and ‘Total Website Sessions’. 

Step-15: Click on the ‘Save’ button at the bottom right-hand side to save the new calculated field:

save button

Step-16: Click on the ‘All Fields’ button in order to navigate back to the data source schema editor:

All Fields

You should now be able to see the new calculated field called ‘Ecommerce Conversion rate’ in the data source schema:

new field 1

Step-17: Click on the ‘Add a field’ button to create a new calculated field called ‘Product Revenue’ and then enter the following formula:

create a new calculated field called Product Revenue

Here we are using the arithmetic operator ‘multiplication’ denoted by * between the two numeric fields: ‘Quantity’ and ‘Average Price’. 

Step-18: Click on the ‘Save’ button and then navigate back to the data source schema editor by clicking on the ‘All Fields’ button.

Step-19: Create a new calculated field called ‘Revenue’ and then enter the following formula:

new calculated field called Revenue

Here we are using the arithmetic operator ‘addition’ denoted by + among the following numeric fields: ‘Product Revenue’, ‘Tax’ and ‘Shipping Cost’.

Step-20: Click on the ‘Save’ button and then navigate back to the data source schema editor by clicking on the ‘All Fields’ button.

Step-21: Create a new calculated field called ‘Gross Profit’ and then enter the following formula:

new calculated field called Gross Profit

Here we are using the arithmetic operator ‘subtraction’ denoted by – among the following numeric fields: ‘Product Revenue’, ‘Tax’ and ‘Shipping Cost’.

Step-22: Click on the ‘Save’ button and then navigate back to the data source schema editor by clicking on the ‘All Fields’ button. 

You should now be able to see all the new calculated fields you have created so far:

all the new calculated fields

Step-23: Change the data type of the calculated field ‘Ecommerce Conversion Rate’ to ‘Percent’:

Change the data type of the calculated field 1

Step-24: Change the data type of the calculated fields: ‘Gross Profit’, ‘Product Revenue’ and ‘Revenue’ to ‘Currency (USD – US Dollar ($))’:

Change the data type of the calculated fields

Step-25: Click on the ‘Create Report’ button:

create report google data studio

Step-26: Click on the ‘Add to Report’ button:

Add to Report google data studio

Your new report may look like the one below:

new report look

Step-27: Add the following fields to this table:

  1. Total Transactions
  2. Total Website Sessions
  3. Quantity
  4. Average Price
  5. Tax
  6. Shipping Cost

You can add these fields by dragging them one by one from the ‘Available Fields’ section to the ‘Dimensions’ section in the property panel:

new property panel

Once you have dragged and dropped all the required fields from the ‘Available Fields’ section to the ‘Dimensions’ section, your property panel may look like the one below:

new look

Step-28: Resize your data table:

Resize table
resized table

Step-29: Remove the ‘Record Count’ field from the data table by hovering your mouse over the ‘Record Count‘ metric in the property panel and then clicking on the cross button next to the metric:

remove record count

Your data table would now look like the one below:

new table

Step-30: Click on the ‘Style’ tab in the property panel:

Style tab

Step-31: Click on the ‘Header font color’ drop-down menu (under the ‘Table Header’):

header font color

Step-32: Set the color to white:

Select white

Step-33: Click on the Header background color drop-down menu (under ‘Table Colors’):

header background colour

Step-34: Set the color to red:

colours

Your data table would now look like the one below:

red table

Step-35: Right-click on the table and then select ‘Duplicate’ to create a copy of the table:

duplicate

Once you clicked on the ‘Duplicate’ button you are going to see a copy of the table:

Copy of table

Step-36: Re-arrange this new table so that it appears right below the old table. You can do that by dragging it down:

double table

Step-37: Select the second data table and then remove the following fields from it: ‘Total Transactions’, ‘Total Website Sessions’, ‘Quantity’, ‘Average Price’, ‘Tax’ and ‘Shipping Cost’.

You can remove these fields one by one by hovering your mouse over the relevant dimension and then clicking on the cross button next to it:

remove field

Once all the specified dimensions are removed, your report would look like the one below:

next table

Step-38: Add the following dimensions to the second data table: ‘Ecommerce Conversion Rate’, ‘Product Revenue’, ‘Revenue’ and ‘Gross Profit’.

You can add these dimensions one by one by dragging them from the ‘Available Fields’ column and then dropping them in the ‘Dimensions’ section in the property panel:

add new dimensions 1

Your report would now look like the one below:

new fields added

Step-39: Re-size the second data table like the one below:

second table resize

Step-40: Change the header color of the second table to blue so that it looks different from the table above:

math fields

That’s how you can do basic maths with numeric fields via the calculated fields.

Other articles on Looker Studio

  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. How to work with the Boolean field in Looker Studio
  9. Looker Studio Page Navigation Tutorial
  10. Understanding Report Editor in Looker Studio
  11. Best practices for creating a report in Looker Studio
  12. How to share reports in Looker Studio
  13. Seven methods to create a new report in Looker Studio
  14. Looker Studio Report Tutorial
  15. How to invite people to view or edit a report in Looker Studio
  16. How to share the link of your report in Looker Studio
  17. Schedule email delivery of a report in Looker Studio
  18. How to download Looker Studio report as PDF
  19. How to embed a Looker Studio report on a website
  20. Guide to Data Types in Looker Studio
  21. Image function in Looker Studio
  22. Image Link data type in Looker Studio
  23. Image data type in Looker Studio
  24. Looker Studio Geo Map – Latitude Longitude
  25. Why You Should Avoid Using Functions and Calculated Fields in Looker Studio
  26. Looker Studio Calculated Fields Tutorial
  27. Working with the Text data type in Looker Studio
  28. The Data Set Configuration Error in Looker Studio
  29. Data Source Fields in Looker Studio – Tutorial
  30. Refresh data source schema fields in Looker Studio
  31. Looker Studio Data Sources – Tutorial
  32. Looker Studio Dimension vs Metric
  33. How to filter by email in Looker Studio
  34. Looker Studio – Sharing Data Sources (aka data source schema)
  35. Field editing in reports – Looker Studio
  36. Data Source Version History in Looker Studio
  37. Community Visualization Access in Looker Studio
  38. Understanding Data Source Credentials in Looker Studio
  39. Understanding Data Freshness in Looker Studio
  40. How to create and configure a data source in Looker Studio
  41. Looker Studio Aggregation Explained
  42. How to Edit a Calculated Field in Looker Studio
  43. Formula Rejection in Looker Studio

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