What is the use of the ZN statement in tableau

This recipe explains what is the use of the ZN statement in tableau

Recipe Objective:-What is the use of the ZN statement in tableau?

The ZN function returns the given expression if it's not null or otherwise returns zero.

Sentiment Analysis Project on eCommerce Product Reviews with Source Code

Syntax of the ZN Function:

ZN(expression)

Example: ZN([Sales])

Step 1:-

Import any data set in the data source. For example, here, the "Sample sales data" data set excel file is imported.

Step 2:-

Drag and drop the orders sheet in the schema pane.

Step 3:-

Go to sheet1; here, different dimensions and measures are available. Click on the drop-down available at the top right corner under the dimensions.

Step 4:-

Now Click on the Create Calculated Field option, a window named Calculation1 will appear. We can rename it to "Profit zn."

Step 5:-

Go to the window of "Profit zn" and type ZN[Profit]. After the ZN statement is made, click on apply and ok. If there is a Null value, it will indicate zero (0); otherwise, it will show the value. A new field named "Profit zn" will appear under the measures.

Step 6:-

Now Double click on "Profit zn," it will appear on the row shelf. Double click on the profit measure (sum of profit), it will appear on the column shelf. Now double click on state dimension so that it will appear in detail under the marks card.

Step 7:-

To simplify the bar chart displayed in the worksheet canvas, click on the show me tab and select the text table, then it appears in tabular form. Here we can observe that the "Profit zn" and "Profit" measures are filled. There are no null values, so the "ZN" statement is satisfied.

Step 8:-

Use the statement as ZN[Profit] during calculated fields.

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

Build a Autoregressive and Moving Average Time Series Model
In this time series project, you will learn to build Autoregressive and Moving Average Time Series Models to forecast future readings, optimize performance, and harness the power of predictive analytics for sensor data.

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

Build a Multi Touch Attribution Machine Learning Model in Python
Identifying the ROI on marketing campaigns is an essential KPI for any business. In this ML project, you will learn to build a Multi Touch Attribution Model in Python to identify the ROI of various marketing efforts and their impact on conversions or sales..

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Build a Graph Based Recommendation System in Python-Part 2
In this Graph Based Recommender System Project, you will build a recommender system project for eCommerce platforms and learn to use FAISS for efficient similarity search.

AWS MLOps Project for ARCH and GARCH Time Series Models
Build and deploy ARCH and GARCH time series forecasting models in Python on AWS .

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Locality Sensitive Hashing Python Code for Look-Alike Modelling
In this deep learning project, you will find similar images (lookalikes) using deep learning and locality sensitive hashing to find customers who are most likely to click on an ad.

MLOps AWS Project on Topic Modeling using Gunicorn Flask
In this project we will see the end-to-end machine learning development process to design, build and manage reproducible, testable, and evolvable machine learning models by using AWS