Getting Started with Salesforce Einstein Analytics: A Beginner’s Guide to Building Interactive Dashboards [1 ed.] 1484251997, 9781484251997

Build interactive dashboards using Salesforce Einstein analytics. Explore all of your data quickly and easily by providi

564 94 8MB

English Pages 201 [193] Year 2019

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

Getting Started with Salesforce Einstein Analytics: A Beginner’s Guide to Building Interactive Dashboards [1 ed.]
 1484251997, 9781484251997

Table of contents :
Table of Contents
About the Author
About the Technical Reviewer
Acknowledgments
Foreword
Introduction
Chapter 1: Einstein Analytics: Introduction
Getting the Right Term
Integration with Salesforce
Why Einstein Analytics?
Environment and Licenses
Einstein Analytics Permissions
Navigating Einstein Analytics
Mobile App
Einstein Analytics Components
Apps
Dashboards
Lens
Datasets
Understanding Data Manager
Monitor
Dataflows and Recipes
Data
Connect
Summary
Chapter 2: Data Sources
Getting Data into Einstein Analytics
CSV File
Local Salesforce Data
External Data
Existing Datasets
Salesforce Trend Report
Create an Opportunity Report
Trend Setting
Verify the Dataset and Dashboard
On Schedule Date/Time
Dataset Fields
Trend Dashboard
External Data API
Summary
Chapter 3: Dataflow and Recipe
Getting Started with Dataflow
Dataflow User Interface
Dataset Builder
Dataflow Transformation
datasetBuilder
sfdcDigest
digest
edgemart
append
augment
computeExpression
computeRelative
dim2mea
flatten
filter
slideDataset
update
sfdcRegister
export
Creating a Dataflow from Scratch
Use Case
Building Concept
Hands-on
Backup and Restore Dataflow
Create Dataset with Recipe
Add Data
Append Data
Additional Transformations in Recipe
Summary
Chapter 4: Dataset
Dataset Properties
Dataset Fields
Extended Metadata File
Rename Field Label
Hide Field
Edit Values
Format Number
Default Fields
Specify the Dataset Grain Label
Replace and Restore Dataset
Configure Action for Dataset
Summary
Chapter 5: Lens
Einstein Analytics App
Creating App
Run App
Share App
Exploring Dataset
Using Chart in Lens
Using Table in Lens
Saving Lens
Present Lens
Explore with Conversational
Clip Lens to Designer
Sharing and Downloading Lens
Get URL
Post to Feed
Download
Summary
Chapter 6: Building the Dashboard
Permission
Layout
Template
Widgets
Chart
Table
Filter
Container
Date
Links
Image
List
Number
Range
Text
Toggle
Navigation
Page
Sharing Widget
Dataset Filter
Dashboard tab
Performance
Adoption and Maintenance
Faceting
Global Filter
Using Multiple Dataset
Summary
Chapter 7: Exploring the Dashboard
Dashboard Inspector
Set Notifications
Hands-On Notifications
Annotations
Enabling Annotations
Hands-On Annotations
Share Widget
Post to Feed
Download
Show Details
Explore
Hands-On Explore Widget
Widget Built with SAQL
Embedding Einstein Analytics Dashboard to Salesforce Page
Hands-On Adding Dashboard to Home Page
Hands-On Adding Dashboard to Record Page
Summary
Chapter 8: Applying Security in Einstein Analytics
Permission Set Assignment
Apps Level Sharing
Security Predicate
Syntax
Hands-On Security Predicate
Role Hierarchy Access
Sharing Inheritance
Enable Sharing Inheritance
Configure Dataflow
Result
Summary
Chapter 9: Advanced Topics
Dataflow Nodes
computeExpression Node
computeRelative Node
slideDataset Node
Filter Node
Append Node
Augment Node with Multiple Value Lookup
LookupSingleValue
LookupMultiValue
Real-Time Data Pull from Salesforce with SOQL
Hands-On
JSON
Dashboard and Lens
Dataflow
Dataset
SAQL
Binding and Static Step
Hands-On Binding and Static Step
Summary
Index

Citation preview

Getting Started with Salesforce Einstein Analytics A Beginner’s Guide to Building Interactive Dashboards — Johan Yu Foreword by Ketan Karkhanis

Getting Started with Salesforce Einstein Analytics A Beginner’s Guide to Building Interactive Dashboards

Johan Yu Foreword by Ketan Karkhanis

Getting Started with Salesforce Einstein Analytics: A Beginner’s Guide to Building Interactive Dashboards Johan Yu

Singapore, Singapore

ISBN-13 (pbk): 978-1-4842-5199-7 https://doi.org/10.1007/978-1-4842-5200-0

ISBN-13 (electronic): 978-1-4842-5200-0

Copyright © 2019 by Johan Yu This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Susan McDermott Development Editor: Laura Berendson Coordinating Editor: Rita Fernando Cover designed by eStudioCalamar Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www.apress.com/ rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/9781484251997. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper

To my wife Novida Lunardi, who always inspired, supported, and encouraged me to make this book a reality.

Table of Contents About the Author��������������������������������������������������������������������������������������������������� xiii About the Technical Reviewer���������������������������������������������������������������������������������xv Acknowledgments�������������������������������������������������������������������������������������������������xvii Foreword����������������������������������������������������������������������������������������������������������������xix Introduction������������������������������������������������������������������������������������������������������������xxi Chapter 1: Einstein Analytics: Introduction�������������������������������������������������������������� 1 Getting the Right Term������������������������������������������������������������������������������������������������������������������ 2 Integration with Salesforce����������������������������������������������������������������������������������������������������������� 2 Why Einstein Analytics?���������������������������������������������������������������������������������������������������������������� 3 Environment and Licenses������������������������������������������������������������������������������������������������������������ 4 Einstein Analytics Permissions����������������������������������������������������������������������������������������������������� 5 Navigating Einstein Analytics�������������������������������������������������������������������������������������������������������� 6 Mobile App������������������������������������������������������������������������������������������������������������������������������� 7 Einstein Analytics Components����������������������������������������������������������������������������������������������������� 7 Apps���������������������������������������������������������������������������������������������������������������������������������������� 8 Dashboards����������������������������������������������������������������������������������������������������������������������������� 8 Lens����������������������������������������������������������������������������������������������������������������������������������������� 8 Datasets���������������������������������������������������������������������������������������������������������������������������������� 8 Understanding Data Manager������������������������������������������������������������������������������������������������������� 9 Monitor���������������������������������������������������������������������������������������������������������������������������������� 10 Dataflows and Recipes���������������������������������������������������������������������������������������������������������� 11 Data��������������������������������������������������������������������������������������������������������������������������������������� 12 Connect��������������������������������������������������������������������������������������������������������������������������������� 13 Summary������������������������������������������������������������������������������������������������������������������������������������ 13 v

Table of Contents

Chapter 2: Data Sources����������������������������������������������������������������������������������������� 15 Getting Data into Einstein Analytics�������������������������������������������������������������������������������������������� 15 CSV File��������������������������������������������������������������������������������������������������������������������������������������� 17 Local Salesforce Data����������������������������������������������������������������������������������������������������������������� 21 External Data������������������������������������������������������������������������������������������������������������������������������ 23 Existing Datasets������������������������������������������������������������������������������������������������������������������������ 25 Salesforce Trend Report�������������������������������������������������������������������������������������������������������������� 25 Create an Opportunity Report������������������������������������������������������������������������������������������������ 26 Trend Setting������������������������������������������������������������������������������������������������������������������������� 27 Verify the Dataset and Dashboard����������������������������������������������������������������������������������������� 28 On Schedule Date/Time��������������������������������������������������������������������������������������������������������� 28 Dataset Fields������������������������������������������������������������������������������������������������������������������������ 29 Trend Dashboard������������������������������������������������������������������������������������������������������������������� 30 External Data API������������������������������������������������������������������������������������������������������������������������ 31 Summary������������������������������������������������������������������������������������������������������������������������������������ 32

Chapter 3: Dataflow and Recipe����������������������������������������������������������������������������� 33 Getting Started with Dataflow����������������������������������������������������������������������������������������������������� 33 Dataflow User Interface�������������������������������������������������������������������������������������������������������������� 34 Dataset Builder��������������������������������������������������������������������������������������������������������������������������� 36 Dataflow Transformation������������������������������������������������������������������������������������������������������������� 41 datasetBuilder����������������������������������������������������������������������������������������������������������������������� 41 sfdcDigest������������������������������������������������������������������������������������������������������������������������������ 41 digest������������������������������������������������������������������������������������������������������������������������������������� 41 edgemart������������������������������������������������������������������������������������������������������������������������������� 42 append����������������������������������������������������������������������������������������������������������������������������������� 42 augment�������������������������������������������������������������������������������������������������������������������������������� 42 computeExpression��������������������������������������������������������������������������������������������������������������� 42 computeRelative�������������������������������������������������������������������������������������������������������������������� 42 dim2mea������������������������������������������������������������������������������������������������������������������������������� 42 flatten������������������������������������������������������������������������������������������������������������������������������������ 43

vi

Table of Contents

filter��������������������������������������������������������������������������������������������������������������������������������������� 43 slideDataset��������������������������������������������������������������������������������������������������������������������������� 43 update����������������������������������������������������������������������������������������������������������������������������������� 43 sfdcRegister�������������������������������������������������������������������������������������������������������������������������� 43 export������������������������������������������������������������������������������������������������������������������������������������ 43 Creating a Dataflow from Scratch����������������������������������������������������������������������������������������������� 44 Use Case�������������������������������������������������������������������������������������������������������������������������������� 44 Building Concept������������������������������������������������������������������������������������������������������������������� 44 Hands-on������������������������������������������������������������������������������������������������������������������������������� 46 Backup and Restore Dataflow����������������������������������������������������������������������������������������������������� 52 Create Dataset with Recipe�������������������������������������������������������������������������������������������������������� 53 Add Data�������������������������������������������������������������������������������������������������������������������������������� 54 Append Data�������������������������������������������������������������������������������������������������������������������������� 54 Additional Transformations in Recipe������������������������������������������������������������������������������������ 55 Summary������������������������������������������������������������������������������������������������������������������������������������ 56

Chapter 4: Dataset�������������������������������������������������������������������������������������������������� 57 Dataset Properties���������������������������������������������������������������������������������������������������������������������� 57 Dataset Fields����������������������������������������������������������������������������������������������������������������������������� 59 Extended Metadata File�������������������������������������������������������������������������������������������������������������� 60 Rename Field Label��������������������������������������������������������������������������������������������������������������� 61 Hide Field������������������������������������������������������������������������������������������������������������������������������� 62 Edit Values����������������������������������������������������������������������������������������������������������������������������� 63 Format Number��������������������������������������������������������������������������������������������������������������������� 64 Default Fields������������������������������������������������������������������������������������������������������������������������ 65 Specify the Dataset Grain Label�������������������������������������������������������������������������������������������� 65 Replace and Restore Dataset������������������������������������������������������������������������������������������������������ 66 Configure Action for Dataset������������������������������������������������������������������������������������������������������� 68 Summary������������������������������������������������������������������������������������������������������������������������������������ 71

vii

Table of Contents

Chapter 5: Lens������������������������������������������������������������������������������������������������������� 73 Einstein Analytics App����������������������������������������������������������������������������������������������������������������� 73 Creating App�������������������������������������������������������������������������������������������������������������������������� 74 Run App��������������������������������������������������������������������������������������������������������������������������������� 75 Share App������������������������������������������������������������������������������������������������������������������������������ 76 Exploring Dataset������������������������������������������������������������������������������������������������������������������������ 76 Using Chart in Lens��������������������������������������������������������������������������������������������������������������� 77 Using Table in Lens���������������������������������������������������������������������������������������������������������������� 79 Saving Lens��������������������������������������������������������������������������������������������������������������������������� 80 Present Lens�������������������������������������������������������������������������������������������������������������������������� 81 Explore with Conversational������������������������������������������������������������������������������������������������������� 81 Clip Lens to Designer������������������������������������������������������������������������������������������������������������������ 83 Sharing and Downloading Lens�������������������������������������������������������������������������������������������������� 84 Get URL���������������������������������������������������������������������������������������������������������������������������������� 85 Post to Feed��������������������������������������������������������������������������������������������������������������������������� 85 Download������������������������������������������������������������������������������������������������������������������������������� 86 Summary������������������������������������������������������������������������������������������������������������������������������������ 86

Chapter 6: Building the Dashboard������������������������������������������������������������������������� 87 Permission���������������������������������������������������������������������������������������������������������������������������������� 88 Layout����������������������������������������������������������������������������������������������������������������������������������������� 88 Template������������������������������������������������������������������������������������������������������������������������������������� 91 Widgets��������������������������������������������������������������������������������������������������������������������������������������� 94 Chart�������������������������������������������������������������������������������������������������������������������������������������� 95 Table�������������������������������������������������������������������������������������������������������������������������������������� 96 Filter�������������������������������������������������������������������������������������������������������������������������������������� 97 Container������������������������������������������������������������������������������������������������������������������������������� 99 Date������������������������������������������������������������������������������������������������������������������������������������� 100 Links������������������������������������������������������������������������������������������������������������������������������������ 101 Image����������������������������������������������������������������������������������������������������������������������������������� 102 List��������������������������������������������������������������������������������������������������������������������������������������� 103

viii

Table of Contents

Number�������������������������������������������������������������������������������������������������������������������������������� 104 Range���������������������������������������������������������������������������������������������������������������������������������� 105 Text�������������������������������������������������������������������������������������������������������������������������������������� 106 Toggle���������������������������������������������������������������������������������������������������������������������������������� 107 Navigation��������������������������������������������������������������������������������������������������������������������������� 108 Page������������������������������������������������������������������������������������������������������������������������������������������ 110 Sharing Widget�������������������������������������������������������������������������������������������������������������������� 110 Dataset Filter����������������������������������������������������������������������������������������������������������������������� 111 Dashboard tab��������������������������������������������������������������������������������������������������������������������� 111 Performance������������������������������������������������������������������������������������������������������������������������ 111 Adoption and Maintenance�������������������������������������������������������������������������������������������������� 112 Faceting������������������������������������������������������������������������������������������������������������������������������������ 112 Global Filter������������������������������������������������������������������������������������������������������������������������������� 113 Using Multiple Dataset�������������������������������������������������������������������������������������������������������������� 114 Summary���������������������������������������������������������������������������������������������������������������������������������� 117

Chapter 7: Exploring the Dashboard��������������������������������������������������������������������� 119 Dashboard Inspector����������������������������������������������������������������������������������������������������������������� 120 Set Notifications������������������������������������������������������������������������������������������������������������������������ 122 Hands-On Notifications�������������������������������������������������������������������������������������������������������� 122 Annotations������������������������������������������������������������������������������������������������������������������������������� 125 Enabling Annotations����������������������������������������������������������������������������������������������������������� 125 Hands-On Annotations��������������������������������������������������������������������������������������������������������� 126 Share Widget����������������������������������������������������������������������������������������������������������������������������� 127 Post to Feed������������������������������������������������������������������������������������������������������������������������� 127 Download����������������������������������������������������������������������������������������������������������������������������� 128 Show Details����������������������������������������������������������������������������������������������������������������������������� 128 Explore�������������������������������������������������������������������������������������������������������������������������������������� 129 Hands-On Explore Widget���������������������������������������������������������������������������������������������������� 130 Widget Built with SAQL�������������������������������������������������������������������������������������������������������� 131

ix

Table of Contents

Embedding Einstein Analytics Dashboard to Salesforce Page�������������������������������������������������� 132 Hands-On Adding Dashboard to Home Page����������������������������������������������������������������������� 133 Hands-On Adding Dashboard to Record Page��������������������������������������������������������������������� 135 Summary���������������������������������������������������������������������������������������������������������������������������������� 138

Chapter 8: Applying Security in Einstein Analytics���������������������������������������������� 139 Permission Set Assignment������������������������������������������������������������������������������������������������������ 140 Apps Level Sharing������������������������������������������������������������������������������������������������������������������� 141 Security Predicate��������������������������������������������������������������������������������������������������������������������� 141 Syntax���������������������������������������������������������������������������������������������������������������������������������� 142 Hands-On Security Predicate���������������������������������������������������������������������������������������������� 143 Role Hierarchy Access��������������������������������������������������������������������������������������������������������� 145 Sharing Inheritance������������������������������������������������������������������������������������������������������������������� 147 Enable Sharing Inheritance������������������������������������������������������������������������������������������������� 148 Configure Dataflow�������������������������������������������������������������������������������������������������������������� 148 Result���������������������������������������������������������������������������������������������������������������������������������� 149 Summary���������������������������������������������������������������������������������������������������������������������������������� 150

Chapter 9: Advanced Topics��������������������������������������������������������������������������������� 151 Dataflow Nodes������������������������������������������������������������������������������������������������������������������������� 151 computeExpression Node���������������������������������������������������������������������������������������������������� 152 computeRelative Node�������������������������������������������������������������������������������������������������������� 156 slideDataset Node��������������������������������������������������������������������������������������������������������������� 159 Filter Node��������������������������������������������������������������������������������������������������������������������������� 160 Append Node����������������������������������������������������������������������������������������������������������������������� 160 Augment Node with Multiple Value Lookup������������������������������������������������������������������������������ 162 LookupSingleValue�������������������������������������������������������������������������������������������������������������� 162 LookupMultiValue���������������������������������������������������������������������������������������������������������������� 162 Real-Time Data Pull from Salesforce with SOQL���������������������������������������������������������������������� 163 Hands-On����������������������������������������������������������������������������������������������������������������������������� 163

x

Table of Contents

JSON����������������������������������������������������������������������������������������������������������������������������������������� 165 Dashboard and Lens������������������������������������������������������������������������������������������������������������ 165 Dataflow������������������������������������������������������������������������������������������������������������������������������ 166 Dataset�������������������������������������������������������������������������������������������������������������������������������� 166 SAQL����������������������������������������������������������������������������������������������������������������������������������������� 166 Binding and Static Step������������������������������������������������������������������������������������������������������������ 169 Hands-On Binding and Static Step�������������������������������������������������������������������������������������� 169 Summary���������������������������������������������������������������������������������������������������������������������������������� 173

Index��������������������������������������������������������������������������������������������������������������������� 175

xi

About the Author Johan Yu has more than 20 years of experience working in the IT sector across MNCs and at a leading Salesforce consulting company in the Asia-­Pacific region. He has spent more than 14 years working with Salesforce technology, starting his career as a developer, team leader, and technical manager, among many other challenging roles. Based in Singapore, Johan holds 13X Salesforce certifications, ranging from Administrator to Architect/Designer certifications, and Einstein Analytics and Discovery Consultant. In his spare time, he enjoys writing blogs and answering questions in the Salesforce Trailblazer Community. In May 2014, Johan became the first Salesforce MVP from Southeast Asia. He is also the leader of the Salesforce Singapore User Group and is keen to help members solve issues related to configuration, implementation, and adoption until more technical issues arrive.  

xiii

About the Technical Reviewer Sayantani Mitra is a Salesforce Analytics Champion specializing in data-driven descriptive and predictive analytics for commercial real estate with actionable insights using Einstein Analytics and Discovery. She takes a keen interest in analyzing and deriving various insights from large datasets. She maintains a blog (on Einstein Analytics (https://medium.com/einstein-analytics) and is the current organizer of the Einstein Analytics Chicago User Group. Sayantani has a Masters in Applied Urban Science and Informatics from New York University and works as a Data Scientist and Einstein Analytics Specialist in Chicago.  

xv

Acknowledgments I would like to take this opportunity to recognize and to say thank you to a number of people who directly or indirectly contributed to this book. Writing this book was quite a journey, and I am grateful for every opportunity, support, and input. •

Chris Varr: My boss, without the wonderful opportunity given to learn Einstein Analytics, this book would never exist. Thank you for the support and belief in me #bestbossever.



My teammates: Eileen, Adrian, Swapna, Masako, Jesus, and Terry, you guys are the best; it is a pleasure to work with all of you.



Sayantani Mitra: One of the most knowledgeable #datatribe, thank you for your sharing, help, and input as a technical reviewer of this book.



Peter Lyons: You teach thousands of people learning Einstein Analytics with your YouTube videos; you are rad, truly an MVP!



Jennifer Shier: An amazing trailblazer and a very positive person, thank you for getting me into the #datatribe clan.



Rita Fernando and Susan McDermott: Thank you Rita and Susan, for every support provided in making this book become a reality.



Ketan Karkhanis: Thank you for the foreword and building such a great product, so we can build intelligence dashboards easily.



David Gibbons: Thank you for the support to Einstein Analytics trailblazers community, and yeah #AnalyticsChampion rocks!

xvii

Foreword In the contemporary enterprise, data now drives business. But data in itself is not of much use. You have to be able to use it to drive business improvements for it to actually matter. Data is just the raw material – you need tools and a strategy to get the most out of it. Additionally, in the age of AI, the dashboard is getting transformed into an intelligent experience. In such an experience, users aren’t spending all their time searching for the data they need. That equation is flipped: the relevant data finds them, and they then use it in a business process that has a narrative element to make important business decisions. However, if you stocked a kitchen with every advanced cooking tool but then put someone who does not have the skills to even boil water in charge of making a four-­ course meal, you wouldn’t expect great results. This book will help you become a master chef of the insights cuisine. This book gives everyone the power to build intelligent experiences. For a generation, analytics dashboards were clumsy and monolithic and mostly told us what had already happened. Today, that’s no longer the case. With the help of this book, you will learn how to elevate it to a whole new level as a strategic tool and design intelligent experiences for the user such that the user walks away with the knowledge of what happened, why it happened, what will happen, and what they should do about it. In technical terms, this boils down to descriptive, diagnostic, predictive, and prescriptive analytics. The key here is complete. Answers to all the questions. Because the “what” and the “why” give context. Then “what will happen” and “what should I do about it” answers give guidance. “Context plus guidance, when delivered as narrative explanations infused in the business process such that data finds you, is equal to an intelligent experience.” Johan Yu, Salesforce MVP in Asia, has a deep understanding and knowledge of Salesforce Einstein Analytics technology, but he is a trailblazer. Not just a master of the technology but a pioneer of new ideas, driving transformation. He is a leader in the Salesforce community, and beyond that, his ideas have also directly influenced numerous product capabilities in Einstein Analytics.

xix

Foreword

This book is aimed at Salesforce administrators, business users, and managers who use Salesforce for their daily work. However, Einstein Analytics is not just for Salesforce. So, any business or data analyst in the world will gain valuable skills that will empower them to drive a data-driven transformation in their organization. Once you have the right skills and vision in place, you can use Einstein Analytics to ensure intelligent experiences can occur; your business processes can leverage analytics in a new way that helps to spur a lasting competitive advantage. Using data in this way can be differentiating in a way that normal interactions with data cannot. I think we’ll see more companies recognizing that they need these types of insights to stay ahead in the future. Ketan Karkhanis SVP Product and GM, Einstein Analytics at Salesforce

xx

Introduction Salesforce is known as the most user-friendly enterprise application; over more than 20 years, it has been evolved from just a simple CRM on the cloud to comprehensive applications for Sales, Service, Marketing, and so on, including Analytics. One of the features liked the most by Salesforce users is the report and dashboard; each user with permission enabled will be able to build and edit report and dashboard on their own. Furthermore, the result of the report is almost instant. Users will be able to sort, group, add subtotal, add bucket fields, and add summary fields and chart to the report. Salesforce dashboard is built on top of reports created, which serve as the data source for each dashboard component. Salesforce report and dashboard serve well as a simple operation analytics tool, but it is not designed to work with large amounts of data, it is not designed as a data analysis and exploration tool, and it does not support connecting to the external data source. Therefore, Salesforce introduces Einstein Analytics. Einstein Analytics is a cloud-based analytics tool; it is tightly connected to the Salesforce platform, but it is also able to get external data into the platform, including from multiple Salesforce org. Einstein Analytics is built for data exploration, so performance is one of the key benefits offered by Einstein Analytics because the datasets are stored within Einstein Analytics, not in Salesforce platform. We can enable one-way data sync from Salesforce to Einstein Analytics, but this does not mean all data from Salesforce will sync into Einstein Analytics, but only objects and fields used in the dataflow. As an Einstein Analytics dashboard builder, you need to prepare the dataset, and this dataset will be used as the data source for dashboards. You can use multiple datasets within a dashboard; then you can link the datasets with a common value. To build datasets, normally you need to design a dataflow. In the dataflow, you architect how the data flows, from extracting data from Salesforce or from the existing dataset in Einstein Analytics, including dataset synced from the external system or from other Salesforce org. You are free to use your own creativity to transform the data in the dataflow, using transformation nodes provided to get data, augment data, filter, append, create new fields based on criteria, and store the transformed data into datasets. You can schedule dataflow to run every hour, daily, or weekly. xxi

Introduction

Einstein Analytics also offers recipe to enrich the existing dataset with other datasets. You also use a recipe to analyze data. Same as a dataflow, you can schedule recipe too. Another option to get Salesforce data into Einstein Analytics is to use trend. Data will be pushed into Einstein Analytics periodically; this is most useful when you want to build trending, another use case to use trend because you need to get fields that exist in Salesforce reporting only. To offer our users with more flexibility in exploring dashboard, we can implement binding, so the dashboard widget is no longer static, for example, using the same chart and giving options for users to change the grouping or showing a line in a chart based on other numbers. Once the dashboard is built, another cool feature is the ability to facet and broadcast across widgets with the same dataset, or linked datasets. This feature is very helpful for the user in analyzing data. Users also will be able to explore widget to the lens and save it for future usage, annotate widget, and set notifications when widget reaches a number that the users set. Security is always required in an analytics tool; Einstein Analytics offers capabilities to make the dashboard only visible to particular users. Dashboard builder is also able to set row-level security with security predicate, and also security inheritance to inherit records visibility from Salesforce rules. To start learning Einstein Analytics, you need to have an org.; if your company has not purchased Einstein Analytics, you can register for a free Trailhead DE org. Thank you for purchasing this book; if you read till the end of the book and follow the hands-on provided, you should have absorbed all features offered by Einstein Analytics and knowledge to build interactive dashboards for your company or your clients. Happy learning!

xxii

CHAPTER 1

Einstein Analytics: Introduction Einstein Analytics is a cloud-based business intelligence and visualization platform from Salesforce, designed to give you insights from your existing data. It also provides predictions and recommendations by analyzing your Salesforce data and external data. The data visualization is optimized for both web browser and mobile app. Einstein Analytics can be embedded into your Sales Cloud or Service Cloud to empower your Salesforce users to explore dashboards and analyze data without the need to switch platforms. To get more understanding of Einstein Analytics, check out www.salesforce. com/products/einstein-analytics/overview/. If you are familiar with Salesforce reports and dashboards, you may need to reset your mind when building an Einstein Analytics dashboard, because the concept of building one is a lot different compared to building a standard Salesforce dashboard. In Einstein Analytics, you do not need to create a report as source data for the dashboard, because Einstein Analytics dashboard will pull data directly from Einstein Analytics data source. This book is written for Salesforce administrators, Salesforce report and dashboard specialists, business intelligence professionals, data analysts, business analysts, and reporting analysts who want to learn to build Einstein Analytics dashboards without any prior experience with Einstein Analytics. This book is also intended for managers and decision makers who use and explore Einstein Analytics dashboards in their daily jobs, so they can make the most of Einstein Analytics features. Throughout this book, step-by-step instructions will guide you in exploring the dashboards as well as building interactive dashboards, from dataset creation, creating dataflow and recipes through designing dashboards optimized for both web browsers and mobile apps and dashboard security.

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_1

1

Chapter 1

Einstein Analytics: Introduction

This chapter covers •

Introduction of Einstein Analytics and its relation with Salesforce platform



Setting up the environment, licensing, and permission



Navigating Einstein Analytics and components of Einstein Analytics



Understanding Data Manager

Getting the Right Term In the past, Einstein Analytics was known as Wave or Wave Analytics or Analytics Cloud. In the documentation and user interface, it may use shortened name “Analytics,” for example, component name in Salesforce Change Set for Einstein Analytics starts with “Analytics.” Another term that we need to get right is Einstein. In the last few years, Salesforce has used “Einstein” as a descriptor in many of their new products. But for this book, we will discuss only Einstein Analytics, and not other Einstein products (e.g., Einstein Activity Capture, Einstein Next Best Action, Einstein Prediction Builder, Sales Cloud Einstein, etc.).

I ntegration with Salesforce If you have experience working with the Salesforce platform, this knowledge will help you in understanding Salesforce objects and fields. However, Einstein Analytics is a platform by itself – the data is stored on its own platform, not stored in Salesforce. Therefore, only the data needed by dashboards must be incorporated into Einstein Analytics. This also means that, ideally, not all data in Salesforce will be available in Einstein Analytics. However, for certain needs, you will be able to query real-time local Salesforce data from Einstein Analytics with Salesforce Object Query Language (SOQL). Because Einstein Analytics is a Salesforce product, it offers you the ability to embed Einstein Analytics dashboards easily into a Lightning App Builder. Users with Einstein Analytics permissions will be able to explore dashboards they have access to from the Analytics tab within the Salesforce user interface, or from the Analytics Studio app (see Figure 1-1). As a dashboard builder, you need to open the Analytics Studio app to create or edit a dashboard or work with dataflow. The Analytics tab and Analytics Studio app will not be visible for users without Einstein Analytics permissions. 2

Chapter 1

Einstein Analytics: Introduction

Figure 1-1.  Analytics Studio is available in the Salesforce Lightning App Launcher

Why Einstein Analytics? With Einstein Analytics, users are empowered to explore and analyze data on their own. The Einstein Analytics dashboard does not depend on Salesforce objects structures; therefore as a dashboard designer, you are free to create datasets, recipes, dataflows, and dashboards with your own creativity. Einstein Analytics is designed to handle millions of rows/records; therefore it can handle interactive dashboards and present the chart or widgets in seconds. Since you are probably using Salesforce, which comes with a robust standard report and dashboard, do you still need Einstein Analytics? It depends on your needs and size of data. See Table 1-1 for a comparison between Einstein Analytics and standard Salesforce report and dashboard.

3

Chapter 1

Einstein Analytics: Introduction

Table 1-1.  Comparison Between Einstein Analytics and Salesforce Report and Dashboard Einstein Analytics

Report and Dashboard

Data source

Salesforce and external

Salesforce

Relationships

Multiple levels

3 levels

Rows

1 billion and above*

2k display

Data availability

Schedule

Real time

Structure

Big data

Operation

Mobile app

Analytics

Salesforce

Data load

REST and External Data API

SOAP/REST/Bulk API

* Note: Einstein Analytics Plus license gives 1 billion rows, while Einstein Analytics Platform license gives 100 million rows to start with.

E nvironment and Licenses If you are an existing Sales Cloud or Service Cloud customer, you need to purchase Einstein Analytics license to use Einstein Analytics (contact your Salesforce AE for the pricing and information of the different types of Einstein Analytics license). If you have already purchased Einstein Analytics, you can – and should – learn to build Einstein Analytics dashboard in a sandbox environment, before deploying into production. However, if your company has not purchased Einstein Analytics, and you would like to learn Einstein Analytics, you can sign up for a free Trailhead Developer environment with Einstein Analytics from the following URL: https://developer.salesforce.com/ promotions/orgs/analytics-de. This Trailhead environment will allow you to learn almost all items that will be discussed in this book. To check if your Salesforce environment has Einstein Analytics enabled, go to Setup and type Analytics in Quick Find text box; if you see the Setting setup menu under Analytics, your Salesforce environment is enabled with Einstein Analytics. Another option is to navigate to company information in the setup menu and look for Analytics Platform or Einstein Analytics Plus in the Permission Set Licenses group (see Figure 1-2), where you will see the number of Einstein Analytics licenses purchased and remaining. 4

Chapter 1

Einstein Analytics: Introduction

Figure 1-2.  Einstein Analytics licenses can be found in Salesforce company information

Einstein Analytics Permissions As Einstein Analytics licenses are sold separately, each Salesforce user must have an Einstein Analytics license granted to access Einstein Analytics dashboard; otherwise the users will not be able to build Einstein Analytics dashboard or explore Einstein Analytics dashboard built. In Einstein Analytics, the license type for a dashboard builder and a dashboard explorer is the same. To check if a user has been given with Einstein Analytics license, go to user detail in Salesforce, scroll down to Permission Set License Assignments related list, and look for Analytics Platform or Einstein Analytics Plus, as shown in Figure 1-3. This license name depends on the type of Einstein Analytics purchased. We will discuss Einstein Analytics user permissions in Chapter 8, which will include assigning Einstein Analytics permissions and permission set.

Figure 1-3.  Finding Einstein Analytics licenses for a user

5

Chapter 1

Einstein Analytics: Introduction

Navigating Einstein Analytics Because Einstein Analytics is a Salesforce product, it integrates well into the Salesforce platform. A Salesforce user can access Einstein Analytics dashboard from multiple places: •

Lightning page: Salesforce systems admins can add the Einstein Analytics dashboard to any Lightning page, such as from the Home page or a record page (Account, Opportunity, etc.). For display on the dashboard in a record page, Salesforce can pass the record ID as a filter to the dashboard, so that the dashboard only shows the relevant data. Salesforce system admin just needs to edit from Lightning App Builder to add the Einstein Analytics Dashboard component.



Analytics tab: Once Einstein Analytics is enabled to your Salesforce environment (org.), the Analytics tab will be added to your Salesforce org. Your Salesforce administrator must configure the tab visibility, either by profile or permission set. This is similar as per the normal Salesforce tab, and your Salesforce admin can set it as Default On, Default Off, or Tab Hidden. From the Analytics tab, the user is able to explore all apps, dashboards, and lens that users have access to. From here, users are also able to track notifications added.



Analytics Studio: The Analytics Studio app is primarily for dashboard builders to build or edit Einstein Analytics dashboards, starting from building the dataset to defining security and so on. Dashboard builders also have the ability to open Data Manager from Analytics Studio.

Standard users can explore apps, dashboards, lens, and dataset from Analytics Studio. There are two ways to open Analytics Studio app (see Figure 1-4): 1. Analytics tab: Click the arrow at the right of apps or dashboard or lens and select “Open in Analytics Studio.” 2. Analytics Studio app: Click App Launcher (nine dots at the top left in Salesforce Lightning), then click Analytics Studio. 6

Chapter 1

Einstein Analytics: Introduction

Figure 1-4.  Analytics Studio user interface

Mobile App Users can download the “Analytics” mobile app from App Store for iOS, or from Google Play Store for Android. As a designer, you should design dashboards layout optimized for mobile or for tablet. If the mobile or tablet layout has not been created, the mobile app will be using the default app where the layout may not appear the best in mobile.

Einstein Analytics Components So far, we have discussed that dashboard is the visualization for users to explore and analyze data, but behind that, there are a lot of components that support in building a dashboard in Einstein Analytics; we mentioned widget, dataset, and data manager in a glance. Now, let’s go through each component in Einstein Analytics.

7

Chapter 1

Einstein Analytics: Introduction

Apps If you are familiar with Salesforce reports and dashboards, you know that they are stored in a folder which controls the report and dashboard accessibility. An app in Einstein Analytics is similar to a folder in Salesforce, where it controls who can view, edit, or manage items within the app. Apps are also similar to containers that can hold multiple types of items, where they can store dashboards, lens, and datasets. Ideally, you should put all related items within an app, then you can configure the app to be shared with users that need to access the dashboard or lens.

Dashboards The dashboard is a collection of widgets, which consist of charts, tables, filters, containers, dates, links, images, lists, numbers, ranges, texts, toggle, and navigation. Ideally, the dashboard is the result of what we want to achieve; we publish the dashboard to a group of users for them to explore and analyze the data. You can also build a dashboard that contains multiple pages.

Lens The lens is similar to report in Salesforce report. However, the Einstein Analytics dashboard does not need lens as data source in building dashboard widgets, because widget gets the data directly from the data source. When the user explores a widget in a dashboard, it will not impact the dashboard, but it will create a new lens, and users are able to save it if needed for future usage or analysis. The lens in Einstein Analytics can be presented in the form of a chart or table. There are multiple types of charts and tables available in Einstein Analytics, and the same types can be used for the lens.

Datasets Everything you need in building a dashboard or lens starts with the dataset. The dataset contains the data itself as well as extended metadata (XMD). You can configure dataset metadata by opening the dataset to set field formatting, relabel field name, hide certain fields, and edit data values (but this is not bucketing). 8

Chapter 1

Einstein Analytics: Introduction

If the dataset is created from dataflow, it is best practice to create dataflow that produces datasets as per dashboard needs; therefore, the dashboard builder does not need to do the heavy lifting when building a dashboard (e.g., to perform SAQL).

Understanding Data Manager As discussed earlier, you can access the Data Manager from Analytics Studio. Data Manager is intended to be used by Einstein Analytics administrators. From Data Manager, you can build dataflow, create a recipe, monitor jobs run in the last seven days, monitor datasets, and connect to external data. If you have permission to access Data Manager, click the gear icon from Analytics Studio then select Data Manager (see Figure 1-5). This will open a new tab in your web browser and will land you to the first tab, which is Monitor.

Figure 1-5.  Accessing Data Manager from Analytics Studio

9

Chapter 1

Einstein Analytics: Introduction

M  onitor This is the first tab in Data Manager (see Figure 1-6). From this tab, you can monitor running dataflows, which will include scheduled dataflows, scheduled recipes, and scheduled sync jobs. From this tab, you will see historical dataflow and jobs run in the past seven days. Click the refresh icon to refresh the latest status of running dataflows or recipes or data sync. Information from this tab will include •

Dataflow name



Status



Type



Start time



Duration



Message

You can expand the dataflow name to get details from each node:

10



Node name



Status



Node type



Start time



Duration



Rows in



Rows out



Rows failed

Chapter 1

Einstein Analytics: Introduction

Figure 1-6.  Data Manager user interface

Dataflows and Recipes This tab will list all dataflows and Dataset Recipes that have been built. Click the arrow at the end of the dataflow to •

Edit dataflow.



Download dataflow as JSON file: This is to manually back up dataflow; it is good practice to back up before making any changes to existing dataflow.



Upload dataflow from JSON file: You can manually make changes to the downloaded dataflow or restore the downloaded JSON file.



Run dataflow: You can monitor the progress from Monitor tab.



Schedule dataflow: Time-based (hour, day, month) and event-based.



Notifications: Send notifications when dataflow run having warnings, or failure, or all events.



Delete dataflow.

For Dataset Recipes, click the arrow at the end of the dataflow to •

Open recipe



Save as new recipe 11

Chapter 1

Einstein Analytics: Introduction



Run recipe



Schedule recipe



Delete recipe

You can create a new recipe by clicking Create Recipe button under Dataset Recipes tab. However, you only can manually create dataflow if you enable Data Sync with Salesforce data.

Tip To enable data sync, navigate to Salesforce setup menu, type Analytics in Quick Find text box, then click Settings, and select Enable Data Sync and Connections.

Data This tab will show all datasets existing, including •

Dataset name.



Time created.



Created by.



App: Where the dataset is stored.



Number of rows.



Data refreshed: This is dataflow or trend scheduled time, or manual run, or manual load.



Last queried: This is when the last query to the dataset from a dashboard or lens.

If you have sync enabled, you will see an additional sub-tab called connected data. This tab will show all Salesforce objects connected, including from other Salesforce environments and external data sources.

12

Chapter 1

Einstein Analytics: Introduction

C  onnect This tab will only be visible when you enable sync. The Connect tab shows Salesforce objects currently synced between Salesforce and Einstein Analytics, and you can check the sync status by hovering your mouse over the database icon on the left of each object. You also can connect to the external data sources such as other Salesforce org., AWS S3, Microsoft Dynamic CRM, Windows Azure SQL Database, SAP Hana, NetSuite, and many more.

Note If your current Einstein Analytics in production is not enabled for sync, DO NOT enable it without thorough testing, as this may cause issues with your existing dataflow.

S  ummary In this chapter, we learned that Einstein Analytics is a platform by itself and the data is stored in the Einstein Analytics platform (not in the Salesforce platform), but you can configure to sync necessary fields and objects. We discussed why we need Einstein Analytics and the differences with standard Salesforce report and dashboard. Einstein Analytics user provisioning is controlled from Salesforce user detail and permission set. To access Einstein Analytics, your users need to log in to Salesforce and then click the Analytics tab or Analytics Studio app. But to edit or build a dashboard, or work with Data Manager, you must start from Analytics Studio. You can create a free Trailhead Developer edition with Einstein Analytics to learn Einstein Analytics from the basic; this environment will give you all items that you need to learn in building Einstein Analytics dashboard. We end this chapter by walking through permissions, the components within Einstein Analytics, and Data Manager. In Chapter 2, we will discuss data source, and how we can get data into Einstein Analytics platform, so stay tuned!

13

CHAPTER 2

Data Sources In Chapter 1, we learned about what is Einstein Analytics, what are the differences with Salesforce dashboard, and the components in Einstein Analytics, including Analytics Studio and Data Manager. In this chapter, we will dive deep into data sources, or how to get data into Einstein Analytics. As explained in Chapter 1, Einstein Analytics stores the data within the platform itself, where the dataflow can be flowed from multiple sources, including local Salesforce platform, external Salesforce environment, and other external data sources. Einstein Analytics makes it possible to get data from multiple data sources, but if you need to get the data from other external systems (including external Salesforce), you must enable data sync (check out Chapter 1 on how to do this). Once sync is enabled, you will have options to add external data such as enterprise applications, data warehouse, and database services. Data loaded into Einstein Analytics will be stored as datasets.

Getting Data into Einstein Analytics Datasets in Einstein Analytics are the result of importing data into Einstein Analytics, including local Salesforce data, external Salesforce data, external data including CSV files, and other systems or databases. The process could be automated/scheduled or manual data load. If you click Create ➤ Dataset in Analytics Studio, there are a few options, as described in Figure 2-1.

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_2

15

Chapter 2

Data Sources

Figure 2-1.  Options to create a new dataset; external data is not available if sync is not enabled Let us walk through each of them now. However, if you are using Trailhead Developer edition, you may not see the last option “A Salesforce Report” when create dataset, you can check this if your Salesforce environment has Trend Report Data in Analytics permission.

16

Chapter 2

Data Sources

C  SV File A CSV file is the most basic type of data source, but it is still widely used as it is standard, simple, and interoperable by many systems. You can directly load data from a CSV file into Einstein Analytics, but if your data is stored as an Excel file, you first need to save it into CSV format. A CSV file is also a good way to store simple data without many rows (e.g., mapping between data stored in Salesforce with output needed in Einstein Analytics), because this mapping is not supposed to change frequently. Let us start with getting our hands dirty to load a CSV file into Einstein Analytics. In this exercise, we are going to load quota amounts for each sales rep for each quarter. You need to prepare the CSV file as in Table 2-1. For the sake of simplicity, I’ll use Microsoft Excel and save it as a CSV file.

Table 2-1.  Sample Table for Sales Rep Quota Employee Id

Quota Quarter

Quota Amount

A001

2019-03-31

500000

A001

2018-06-30

600000

A001

2019-09-30

600000

A001

2019-12-31

500000

A002

2019-03-31

700000

A002

2018-06-30

750000

A002

2019-09-30

800000

A002

2019-12-31

650000

A003

2019-03-31

400000

A003

2018-06-30

450000

A003

2019-09-30

500000

A003

2019-12-31

400000

17

Chapter 2

Data Sources

Let’s store Table 2-1 as Quota 2019.csv. Now, load the CSV file as a dataset in Einstein Analytics, by following these steps: 1. Open Analytics Studio. 2. Click Create button then select Dataset (see Figure 2-2).

Figure 2-2.  Create a new dataset 3. Click CSV file. 4. Upload the CSV file by selecting the file or dragging it to the box. 5. Click Next to continue. 6. Click Next again; for now, let us use the default dataset name and default app My Private App. 7. Click Upload File button, no need to change anything at this screen too; notice there are three field types: •

Employee Id: Dimension



Quota Quarter: Date



Quota Amount: Measure

8. Done, you can check the progress in Data Manager. 9. Dataset created (see Figure 2-3). 18

Chapter 2

Data Sources

Figure 2-3.  The dataset created 10. Let’s confirm the dataset created by clicking the Analytics Studio tab, then click the Datasets tab. You should then see Quota 2019 dataset (see Figure 2-4).

Figure 2-4.  The new dataset available under “Datasets” tab

19

Chapter 2

Data Sources

11. Click Quota 2019 dataset to open the dataset as a new lens. By default, it will be a horizontal bar chart with the count of rows as bar length, without grouping and without filter. 12. Click Fields next to the dataset name to see all available fields for the dataset (see Figure 2-5).

Figure 2-5.  Check all fields available in a dataset A few important things can be learned from this exercise:

20



The file must be in CSV format, not in Excel or other formats.



By default, the dataset name would be the file name and will be stored in My Private App, but if you click Create Dataset button from an app, the dataset created would be in the source app.

Chapter 2





Data Sources

There are three field types in Einstein Analytics: •

Dimension: Data is stored as text, and you can perform the string functions on this field type.



Date: Data is stored in date format, and Einstein Analytics will auto split it into year, quarter, month, week, and date, and you can use them for grouping, filter, and other usages.



Measure: Data is stored as numbers, and you can perform the numerical functions on this field type.

Navigate to Data Manager to monitor data loading progress.

Local Salesforce Data We can connect Einstein Analytics with multiple data sources, including from local Salesforce, from other Salesforce environments, and from other external data sources. Local Salesforce data means that Einstein Analytics is located at the same environment (org.) with Salesforce platform and sync is not a must to extract data from local Salesforce org. For external Salesforce data, Einstein Analytics are located at different environment with Salesforce, you can get the data into Einstein Analytics by using connected data source, and sync must be enabled in the target Einstein Analytics. See Table 2-2 for comparison between local and external Salesforce.

Table 2-2.  Local Salesforce vs. External Salesforce Local Salesforce

External Salesforce

Relation with Einstein Analytics platform

Einstein Analytics is located here, Do not have any relation with Einstein although the data is not shared Analytics

Data sync

Not a must

Must be enabled

Dataflow

Using sfdcDigest node

Using Digest node

Filter

Can filter with SOQL on sync

Cannot filter on sync

Number of org.

Only one org. is local

Can relate to multiple Salesforce org.

21

Chapter 2

Data Sources

Whether the sync is enabled or not, you need to create a dataflow to extract data from Salesforce data to Einstein Analytics. You also must know which Salesforce objects and fields stored the data that you need. If you have experience in managing Salesforce objects, this will help you in building the dataflow. To create a dataflow, start from Data Manager, and make sure that sync is enabled; otherwise you will not see Create Dataflow button.

Tips  You can use Change Set to deploy dataflow, even if it is a new dataflow that does not exist in the target org., and the target org. does not have sync enabled, the inbound Change Set will create the dataflow as a new dataflow. The Change Set components will start with Analytics, for example, Analytics Dataflow, Analytics Dataset, Analytics Dashboard, and so on. If sync is enabled, data will be extracted from replicated data stored in Einstein Analytics, and therefore the dataflow will run much faster. When you add objects and fields into sfdcDigest node, dataflow will automatically add the objects and fields for sync. But, if sync is not enabled, every time dataflow runs, it will extract directly from Salesforce, and the process will need more time. If sync is enabled, from Data Manager, click Connect tab; by default local Salesforce data will be named as SFDC_LOCAL, and it will show which objects have been synced and which objects have not. At this screen, you can add or remove fields to sync. To sync object has not synced, click Run Data Sync from drop-down arrow at the end of the object. See Figure 2-6 for comparison when sync is enabled or not. Without data sync, dataflow will get the data directly from Salesforce, while when sync is enabled, dataflow will get the data from replicated dataset in Einstein Analytics.

22

Chapter 2 Salesforce

Einstein Analytics

Salesforce

Einstein Analytics

Dataset

Salesforce Objects

Dataset

Data Sources

Dataset

Salesforce Objects

Replicated Datasets

Dataset

Without Data Sync

Dataset

Dataset

With Data Sync

Figure 2-6.  Without data sync and with data sync Once the dataflow is tested and working fine, you can schedule it. If sync is enabled, make sure to schedule the dataflow after sync schedule, and set the dataflow schedule 1-2 hours after sync is scheduled; this depends on the data size and number of objects to be synced. We will discuss building dataflow in detail in Chapter 3.

E xternal Data This option is only available when data sync is enabled. External data could be from other Salesforce org. or from other remote data services. Navigate to Data Manager and click Connect tab to see supported remote connection (see Figure 2-7).

23

Chapter 2

Data Sources

Figure 2-7.  Available options to connect to remote data connection For each connection, you can schedule when to sync from the external data source, including from external Salesforce. Figure 2-8 shows Einstein Analytics connected to local Salesforce org., also connected to another Salesforce platform. In this example, we name the external Salesforce connection as “EA1”, while for local Salesforce connection, by default the connection name is “SFDC_LOCAL”. We can schedule each Salesforce data to sync at different times.

24

Chapter 2

Data Sources

Figure 2-8.  Multiple data source connected to Einstein Analytics Once the external data sources are connected, use dataflow with digest node to pull the data and transform into Einstein Analytics dataset.

E xisting Datasets In many cases, you need to enrich a dataset with other datasets, including content from external sources. It will be too risky to change an existing dataset if it has been used in many dashboards and lens. You can create a recipe or a dataflow using existing datasets to create a new enriched dataset. This will not impact existing datasets, and it is the safest option when the dataset has been used in dashboards or lens. We will discuss both recipe and dataflow options in detail in Chapter 3.

Salesforce Trend Report This is a very powerful yet simple way to trend Salesforce data into Einstein Analytics. With the trend, you can push data directly from a Salesforce report to Einstein Analytics as a dataset. You also do not need to know the Salesforce objects and fields; you just need to create a report in Salesforce and click the Trend button. This option also has extra benefits, if the fields that you need to push to Einstein Analytics are report-only fields, for example, Last Activity, Age, and Fiscal Period in Opportunity report. Dataflow will not be able to retrieve those fields, but trend report will easily get that data.

25

Chapter 2

Data Sources

Basically, the idea of creating trending is to track key metrics over time, so you can see your data growing over time in a dataset. Trending refers to data that is displayed over a timeline, and if the relevant data is plotted over time, questions on sales cycles, performance, comparisons, and more can be seen at a glance. After clicking the Trend button, you need to schedule the frequency and time. Because this is for trending, data pushed into Einstein Analytics will keep being added, not overwritten as per normal dataflow. In addition to creating a new dataset, it will also automatically create a new dashboard in Einstein Analytics. If you are using Trailhead Developer edition, you need to check if you have Trend Report Data in Analytics permission in your Salesforce org.; otherwise, you will not see the Trend button in the report. However, you may have to log a ticket with Salesforce for enabling this permission. Let’s get our hands dirty and work through an exercise to trend a Salesforce report.

Create an Opportunity Report You are free to use any Salesforce reports for this exercise, and Figure 2-9 is my example of an opportunity report. I added “Last Activity” and “Fiscal Period” fields; both are report-only fields. Click the Trend button to continue.

Figure 2-9.  Click Trend button from a Salesforce report 26

Chapter 2

Data Sources

T rend Setting You will be asked for the dataset name, dashboard title, schedule frequency, days, and time. Let’s keep the default dataset and dashboard name, and change the schedule to daily 9:00 PM or anytime you prefer, and then click Trend button at bottom right of the window (see Figure 2-10).

Figure 2-10.  Schedule the Trend from a Salesforce report Alternatively, you also can trend a report from Analytics Studio by clicking Create – Dataset and selecting A Salesforce Report.

27

Chapter 2

Data Sources

Verify the Dataset and Dashboard Once you click the Trend button, the dataflow will run immediately (before the scheduled date and time). This will create a new dataset in Einstein Analytics; you can monitor the progress from Data Manager (see Figure 2-11).

Figure 2-11.  Monitor trend progress for initial trend run Once completed, you should see the new trend dashboard and dataset in My Private App.

On Schedule Date/Time When the schedule date time is run, the dataflow will add data to the existing dataset. You can check in Data Manager that the dataflow nodes are different, and there is additional node called append. If you check the dataset again, the count is double from the initial trend run (see Figure 2-12).

28

Chapter 2

Data Sources

Figure 2-12.  Monitor trend progress on schedule trend run

D  ataset Fields Let’s see what fields are created in the dataset from the trend. Open the dataset as a new lens and change to table format. You should see all fields from Salesforce report exist, including fields used for grouping are created in the dataset. Additionally, a DateTime field called Snapshot Date is added; this is useful to mark when the trend runs in creating rows in dataset (see Figure 2-13).

29

Chapter 2

Data Sources

Figure 2-13.  The table shows fields created in dataset from trend

T rend Dashboard As part of trend from Salesforce, a simple trend dashboard will be created in Einstein Analytics with the data source from the trend dataset (see Figure 2-14).

30

Chapter 2

Data Sources

Figure 2-14.  Trend dashboard

Tips  If you need to have only latest data from Salesforce, instead of keep adding data to existing rows, you can create a dataflow to clean all existing rows; just make sure the dataflow should run before the trend schedule runs.

External Data API This option is not available when you click Create Dataset from Analytics Studio, and this is more targeted for developers. API enables you to upload data to external data into Einstein Analytics, and it can be triggered based on action in other systems. You need a developer to write a script using Einstein Analytics API. We will not discuss this option in this book.

31

Chapter 2

Data Sources

Summary In this chapter, we looked at all possibilities on bringing data into Einstein Analytics, from a simple CSV file, Salesforce data sync, external data sync, to trends from Salesforce reports. We were also able to create a new dataset using the existing dataset with dataflow or recipe. The next chapter discusses building dataflow from scratch as well as with Dataset builder. Dataflow is the most elegant way to build the dataset, so it is very important for a dashboard builder to know dataflow. I will share how to back up and restore dataflow and will close with a session on how to create a recipe.

32

CHAPTER 3

Dataflow and Recipe We discussed how to get data into Einstein Analytics in Chapter 2, including a hands-on CSV file data load exercise, then getting hands-on with trending Salesforce report, where in both exercises a new dataset is created. But we have not discussed dataflow, one of the most important tools in bringing Salesforce data into Einstein Analytics, so let’s start now. Trust me, this chapter will be fun. We will build dataflow from scratch and using dataset builder. You can architect the data transformation and data manipulation to produce datasets required for your dashboard. You also will learn how to use recipes to enrich datasets at the end of this chapter.

Getting Started with Dataflow As mentioned in Chapter 1, the Einstein Analytics dataset is stored on the Einstein Analytics platform. This makes sense because if the data is stored outside Einstein Analytics, the performance will be very bad. In Chapter 2, we discussed multiple methods to get data into Einstein Analytics, including CSV file data load and Salesforce report trend. But so far dataflow has not been discussed. Because of its power and importance, I’ve chosen to treat it separately in this chapter. Dataflow is typically used for data transformation from an existing dataset, from Salesforce data (both sync and not sync) and from external data sources (sync must be enabled). You will be able to create a new dataflow only when sync is enabled. Open Analytics Studio, and select Data Manager tab menu at the left panel, select Dataflow & Recipes tab, and click Create Dataflow button (See Figure 3-1).

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_3

33

Chapter 3

Dataflow and Recipe

Figure 3-1.  Create dataflow from Data Manager

Tip  You can use Change Set to deploy blank dataflow from org. enabled with sync to org. not enabled with sync. Change set deployment is only applicable for org. within the same productions org.

Dataflow User Interface When you open an existing dataflow or create new dataflow, you will be presented with dataflow user interface, as in Figure 3-2. Hover your mouse over each icon in the dataflow user interface to see the icon name. Each icon below the dataflow name represents a node for data transformation. We will discuss each of them in this chapter.

34

Chapter 3

Dataflow and Recipe

Figure 3-2.  Dataflow user interface There are a few more icons and buttons on the top right of the screen, so let’s discuss each of them from right to left: •

Run Dataflow: When the dataflow is ready, click this button to put the dataflow into run queue, then you can navigate to the Monitor tab to see the progress.



Upload JSON: Use this button to upload dataflow file in JSON format from your local computer. It can be an original backup or has been modified.



Download JSON: Use this button to download the dataflow in JSON format to your local computer, as a backup or to modify the dataflow locally. As a backup file – if something went wrong when you modify a running the dataflow, you can restore back the dataflow with this backup file.

35

Chapter 3

Dataflow and Recipe

The other purpose to download dataflow JSON file is to update the dataflow manually. As best practice, always make a copy of the original file before making the changes, open the downloaded JSON file with text editor such as Notepad++, make the changes as necessary, then upload back the changes JSON file. •

Preview JSON: Dataflow is stored in JSON format; click this icon to view the dataflow in JSON format. You also can download the JSON dataflow from here.

The Search nodes text box is useful when you have a lot of nodes in a dataflow. You can type in the text box to filter nodes that you are looking for; you should practice a good naming convention for each type of transformation nodes.

Dataset Builder Dataset builder is meant to provide guidance to extract data from one or many local Salesforce objects and store the result as a dataset in Einstein Analytics. This is kind of similar with wizard style, where you select something and click next to continue. Once the dataflow is built, you can open the dataflow and edit it manually. To make this more interesting, let’s dive into this hands-on dataset builder exercise. Use case: Extract all Account data, including the Account Owner Name: 1. Open Analytics Studio. 2. Navigate to Data Manager, click Dataflows & Recipes tab, then click Create Dataflow button. 3. Name the dataflow as All Account with Owner; click Create button. 4. Click top left icon datasetBuilder – steps 2 to 3 are similar with clicking Create ➤ Dataset ➤ Salesforce Data from Analytics Studio; select “Add to new dataflow,” and enter dataflow name All Account with Owner. 5. Type a name for new dataset – I will name my dataset name as Account_Owner – and click Continue button. 6. Select Account as the object to start.

36

Chapter 3

Dataflow and Recipe

7. Hover your mouse over Account box created and click + icon next to the box. 8. Select fields you want to extract from Salesforce Account into Einstein Analytics; I’ll select Account Name, Account ID, and Account Type. You can type in the text box to search the field. 9. Next, click Relationships tab, and click Join next to Owner ID. You should have your dataflow similar with what is shown in Figure 3-3.

Figure 3-3.  Dataset builder user interface

37

Chapter 3

Dataflow and Recipe

10. Click + icon next to User box, and select First Name and Last Name. 11. Now we have four fields selected from Account and two fields from the User object. 12. Click the Next button to continue. 13. When finished, we have successfully built a dataflow (see Figure 3-4).

Figure 3-4.  Dataflow built successfully 14. Click the Update Dataflow button at the top right screen to save as new dataflow or update existing dataflow. 15. Click the Update Dataflow button again on pop-up window to confirm. 16. Now the Update Dataflow button will change to Run Dataflow. 17. Click the Run Dataflow button to put the dataflow in the queue for run; click Go to Data Monitor to check the progress and result.

38

Chapter 3

Dataflow and Recipe

18. From my testing, it should take only 15 seconds or so to extract all Accounts from replicated data and store the result as a dataset. You can see all the nodes and number of rows processed from Monitor in Figure 3-5.

Figure 3-5.  Monitor completed and in progress dataflow 19. Go back to Analytics Studio, and click Datasets tab. 20. Look for the dataset name that you entered at step 2 in this exercise. In my case the dataset name Account_Owner. 21. Notice that the dataset is stored in Shared App – you can move the dataset to another app; we will discuss dataset in detail in Chapter 4. 22. Click the dataset name to open it as a new Lens, which will be presented in a bar chart without any grouping; the bar length is number of rows. 23. Click Fields to see all available fields for this dataset. This should be the same with fields selected from step 7 to step 9 (see Figure 3-6).

39

Chapter 3

Dataflow and Recipe

Figure 3-6.  Explore fields detail from a dataset with lens From this exercise, with just a few clicks, we can easily create a dataflow to extract data from Salesforce to Einstein Analytics. Let us look at the dataflow created by using dataset builder: •

Two nodes of sfdcDigest: This node is to extract Account and User data.



One node of augment: This node is used to look up data between nodes.



One node of sfdcRegister: This node is used to store data into a dataset.

Tips If your org. is not enabled for sync, you can create a new dataflow from Analytics Studio; click Create ➤ Dataset ➤ Salesforce Data from Analytics Studio, and select “Add to new dataflow.” We will walk through each type of nodes in dataflow in the next section.

40

Chapter 3

Dataflow and Recipe

D  ataflow Transformation The following are all icons available for dataflow transformation; you will be the architect on how and when to use each component. Depending on the type of your Einstein Analytics license, you may see less or more types of nodes available in your Dataflow editor (see Figure 3-7).

Figure 3-7.  Dataflow nodes

d atasetBuilder We have explained the purpose and usage of dataset builder in the previous hands-on exercise, so I’ll not repeat again here.

s fdcDigest Use this node to extract data from an object of local Salesforce org. You must specify the object name and select fields needed, and then you can add a filter if the need is not to get all records. You can extract from all custom objects and all main standard objects. However, some system objects are not supported, so definitely check out this list: https://help.salesforce.com/articleView?id=bi_integrate_salesforce_extract_ transformation_unsupported_objects_fields.htm&type=5 You can have many sfdcDigest in a dataflow, but for a better performance when running the dataflow, whenever possible, try not to have more than one node to extract from the same object.

d igest This node is similar to sfdcDigest, but it supports data extract from connected (sync) data source, for both local Salesforce data and external data sources.

41

Chapter 3

Dataflow and Recipe

edgemart Use this node to extract existing datasets in Einstein Analytics.

append Once the data has been extracted from the source, you can use append node to combine rows from multiple sources. All source data should have the same structure: both field name and type; otherwise, you must enable “Allow disjoint schema”; this option will create all available fields from all nodes.

augment This is one of the most popular nodes in Einstein Analytics data transformation. Imagine this as similar to VLOOKUP() in Microsoft Excel. In the previous dataset builder exercise, we used the augment node to get Account Owner Name because Account object only stores Owner Id, so we matched OwnerId fields from Account with Id field from User.

computeExpression This is also another very popular node in the dataflow, where you can create new fields based on the value from other fields. Imagine this as like adding formula field in Salesforce, but you no need to have the fields physically created in Salesforce.

computeRelative computeExpression helps to calculate new fields value based on other fields value in the same row; use computeRelative transformation to create a new field by comparing the value with other rows.

dim2mea Use this transformation node to create a new measure (number) field by to convert from a dimension (string) field.

42

Chapter 3

Dataflow and Recipe

flatten Use this node to flatten hierarchical data (e.g., role hierarchy), so you can use it for other purposes (e.g., to implement row-level security).

filter Use this node to filter out unnecessary rows, so you will only have data needed for the dashboard. You have the option to use a SAQL filter or standard filter. You may notice in sfdcDigest node that you also can filter out data when fetch it, but adding filter in sfdcDigest will cause issues if you have data sync enabled, so it is better to use filter node to filter data out.

slideDataset In a scenario where you have too many fields in the dataflow but not all are needed for your dashboard, you can set fields to be removed or to be kept.

update Use this transformation to update the value of a field, based on lookup from another dataset. You need to provide the key field for each dataset to match.

sfdcRegister This is the node to register/write all data transformed into a dataset. Every time the dataflow is run, it will overwrite existing dataset values. Once the dataset registers, you can use it for dashboard or lens. sfdcRegister node will not overwrite existing XMD defined for dataset.

export This node makes data in Analytics available for Einstein Discovery. This node creates a data file and a schema file from data in a specified source node in the dataflow. This node is only available when you have Einstein Discovery license. 43

Chapter 3

Dataflow and Recipe

Creating a Dataflow from Scratch Okay, this will be fun. We are going to create a new dataflow from scratch to produce a dataset that will be used for the dashboard. With the dataset, we are free to architect the dataflow, including filters and so on.

Use Case Build a dataflow to extract all Opportunities with the following fields: –– Opportunity Id –– Opportunity Name –– Opportunity Owner –– Account Name –– Is New Business? if Type contains “New Business,” then “Yes,” else “No” –– Opportunity Stage –– Amount With the following criteria –– Only Open and Closed Won opportunity –– Amount must be > $0 The dataflow also needs to include Opportunity Contact Roles – only if the role is Decision Maker. If more than one contact is Decision Maker, randomly pick only one. If there is no Decision Maker, set the label as “Not Available.”

Building Concept Understand and analyze related objects and fields: 1. Determine how many objects are involved? For this use case, it would be four, which are –– Opportunity –– User 44

Chapter 3

Dataflow and Recipe

–– Account –– OpportunityContactRole –– Contact 2. Determine the main object, which will determine the number of rows before the filter. For this use case, the main object is Opportunity. 3. Determine filters for each object: –– Opportunity Stage “Closed Lost” –– Opportunity Amount > 0 –– Opportunity Contact Role = “Decision Maker” 4. Determine fields to extract from each object:

a) Opportunity –– Id –– Name –– OwnerId –– AccountId –– Type –– Amount –– Stage



b) User –– Id –– Name



c) Account –– Id –– Name

45

Chapter 3



Dataflow and Recipe

d) OpportunityContactRole –– ContactId –– OpportunityId –– Role



e) Contact –– Id –– Name 5. Determine the relationship of each object: –– Opportunity.AccountId with Account.Id –– Opportunity.OwnerId with User.Id –– OpportunityContactRole.OpportunityId with Opportunity.Id –– OpportunityContactRole.ContactId with Contact.Id 6. Once you have all the preceding answers, we are ready to rock!

Hands-on Let’s get started with our next hands-on scenario: 1. Open Analytics Studio and then Data Manager. 2. Click Dataflows & Recipes tab, then click Create Dataflow button. 3. Name the dataflow – I will name it as Open Opportunity – then click Create button. 4. Click sfdcDigest nodes 4x for each object; I will name it as –– sfdcDigest_Opportunity –– sfdcDigest_User –– sfdcDigest_Account –– sfdcDigest_OCR (for Opportunity Contact Role) –– sfdcDigest_Contact 46

Chapter 3

Dataflow and Recipe

5. Select the relevant object and fields for each object as in Building Concept step number 4. 6. Before we start the transformation, let us use filter transformation to filter only data that we want, check out Building Concept step number 3, we have two objects to filter: –– Click filter nodes, and name it filter_Opportunity. –– Source = sfdcDigest_Opportunity. –– Select “SAQL Filter,” and type in the following filter: (Amount > 0) && (StageName != “Closed Lost”).

Tip When building a dataflow, you can temporarily add register nodes to debug and check the data at a particular point. 7. Do another filter transformation for Opportunity Contact Role: –– Click filter nodes, and name it filter_OCR. –– Source = sfdcDigest_OCR. –– Select “SAQL Filter”, and type in the following filter: (Role == “Decision Maker”). 8. Because Opportunity only has OwnerId, let us enrich Opportunity with the Owner Name using augment transformation. Name the augment as augOpportunity_User: –– Left Source = filter_Opportunity –– Left Key = OwnerId –– Relationship = “Owner” –– Right Source = sfdcDigest_User –– Right Key = Id –– Right Fields = Id, Name Click the Output Fields tab, and now you should see two additional fields starting with Owner (see Figure 3-8). 47

Chapter 3

Dataflow and Recipe

Figure 3-8.  Augment node with User object for Opportunity Owner 9. The same with step 8, now we are going to get Account Name. Name the augment as augOpportunity_Account: –– Left Source = augOpportunity_User –– Left Key = AccountId –– Relationship = “Account” –– Right Source = sfdcDigest_Account –– Right Key = Id –– Right Fields = Id, Name Click Output Fields tab; now you should see two additional fields start with Account. 48

Chapter 3

Dataflow and Recipe

10. Now we are going to get Decision Maker name from Opportunity Contact Role. Again, add augment node; name it as augOpportunity_OCR: –– Left Source = augOpportunity_Account –– Left Key = Id –– Relationship = “ContactRole” –– Right Source = filter_OCR –– Right Key = OpportunityId –– Right Fields = Name 11. The same previous steps, now we are going to get Contact Name for Opportunity Contact Role (see Figure 3-9). Name the augment as augOpportunity_Contact: –– Left Source = augOpportunity_OCR –– Left Key = ContactRole.ContactId –– Relationship = “Contact” –– Right Source = sfdcDigest_Contact –– Right Key = Id –– Right Fields = Name

49

Chapter 3

Dataflow and Recipe

Figure 3-9.  Augment node with more objects augmented

Tip When building dataflow, remember to click “Update Dataflow” over times to save updated dataflow; this is to make sure your hard work is not lost if something goes wrong with the web browser or the Internet connection. Also, always back up the dataflow JSON file frequently when you are testing the dataflow. That way, when adding new nodes and something goes wrong, you have backup of the JSON file that was working just before that point. 50

Chapter 3

Dataflow and Recipe

12. Add computeExpression node to check if –– Opportunity Type contains “New Business,” then “Yes,” else “No” –– Decision Maker is null, change to “Not Available” Click “+ Add Field” button; I will name it “New Business”; Type = Text, and SAQL Expression = case when starts_with(‘Type’, “New Business”) then “Yes” else “No” end Click “+ Add Field” button again; I will name it “Decision Maker”; Type = Text, and SAQL Expression = case when ‘ContactRole. ContactId’ is null then “Not Available” else ‘Contact.Name’ end Both will add new fields called New Business and Decision Maker. 13. Add a register node to end this dataflow. I’ll name my Node Name, Alias, and Name as regOpty1. 14. Click Update Dataflow button to save the dataflow (see Figure 3-10).

Figure 3-10.  The complete Open Opportunities dataflow

Note If you close and reopen back the dataflow, the position of the nodes would be reorganized by the system, so no need to worry because the logic is not changed. Unfortunately you cannot save your preferred nodes layout, so you have to re-­layout it back if you prefer to. 15. Now let us run the dataflow by clicking Run Dataflow button and click Go to Data Monitor to monitor the progress.

51

Chapter 3

Dataflow and Recipe

16. Back to Analytics Studio, click Datasets tab, and look for regOpty1 dataset. This will open the dataset as a new lens. 17. Change to table mode, by clicking the Table Mode icon, then select Values Table. 18. You can select fields to show by clicking the pencil icon under the Data panel as shown in Figure 3-11. By default, it will show only 100 records. You can change this by click Edit link under Query Limit. Note that the maximum number of rows you can see in a lens without any json editing is 10000 only.

Figure 3-11.  Dataflow open in table mode 19. You can save the lens by clicking the Save icon on the top right menu.

Backup and Restore Dataflow There is no system backup provided by Einstein Analytics to backup dataflow, but you can download the configuration presented in JSON file, download the file from Dataflow editor, and store the JSON file in your local computer or server.

52

Chapter 3

Dataflow and Recipe

Using a text editor such as Notepad++, you can open and modify the JSON file as required. Because when you edit the file manually, this is prone to errors, so the best practice is always to keep a backup of the original JSON file.

Figure 3-12.  Download and upload dataflow JSON file Click (1) to download JSON file and (2) to upload JSON file (see Figure 3-12). To restore a backup file, click Upload JSON. This can be the original JSON file, or a JSON file that has been modified. There are multiple reasons to download and edit JSON file, from finding a field, mass add node, mass update, to comparing JSON files with a previous version.

Create Dataset with Recipe The purpose of recipe is to enrich existing dataset available in Einstein Analytics; enrich here includes adding a transformation, adding new rows or columns based on keys. All data should exist in Einstein Analytics as datasets or connected data from sync.

Note Recipe will always create a new dataset, not overwrite the source dataset. You can schedule a recipe, and this will keep overwrite target dataset. The recipe user interface lets you preview the data in table mode, including field name and field type for each dataset (see Figure 3-13).

53

Chapter 3

Dataflow and Recipe

Figure 3-13.  Recipe user interface Using Data transformation to add row and add column in Einstein Analytics is presented as Add Data (1) and Append Data (2).

Add Data This function is to add columns to source dataset with another dataset based on pair keys; it can be one or multiple pair keys. This function is similar to augment in dataflow or VLOOKUP () in Microsoft Excel.

Append Data When you have two datasets, you can combine the dataset using a recipe. Even if the field’s name is not the same, the mapping field type must be the same. If one of the datasets has extra columns, the value will be null for rows coming from the dataset without that extra field.

54

Chapter 3

Dataflow and Recipe

Additional Transformations in Recipe With recipes, you can implement transformation to a dataset, so it does not always need more than one dataset to use a recipe. The Column Profile provides a quick look of the value from a specific column, including missing values, and field attributes: •

Filter: This will filter only rows that match the criteria.



Bucket: This will bucket values as defined, then will create a new column.



Replace: This is to replace a specific value from a field with other value, then this will create a new column.



Trim: To trim leading and trailing whitespaces, this will create a new column.



Substring: To get specific values from a starting position and length, this will create a new column.



Split: To split a column to multiple columns based on specific characters, such as a comma or semicolon.



Uppercase and Lowercase: To convert the value to Upper case or Lower case, this will create a new column.



Dim2Mea: To convert from text to number, this will create a new column.

The recipe user interface will show you all transformations defined in a recipe at the left panel, so you can trace the transformation easily (see Figure 3-14).

55

Chapter 3

Dataflow and Recipe

Figure 3-14.  Transformation in recipe

Summary We have finally learned one of the most powerful items in Einstein Analytics: dataflow. We reviewed this with hands-on exercises by building dataflow using dataset builder, and from scratch. To create a dataflow, you need to make sure sync is enabled. We learned each transformation offered by Einstein Analytics, from getting data using sfdcDigest or digest or edgemart to using computeExpression node to create new fields based on some login of other fields, to using Augment node to look up and get data from other nodes, and using register node to write the data into a dataset. We also learned how to back up and restore dataflow using JSON file. We ended this chapter by looking into recipes and the data transformations offered by recipes. In the next chapter, we will look into dataset created in Einstein Analytics. It can be created from the CSV file, from dataflow, from Salesforce trend report, and so on. We will also review how to manipulate dataset metadata to produce a dataset as per our business needs.

56

CHAPTER 4

Dataset In Chapter 2, we discussed how to get data into Einstein Analytics. From Analytic Studio, you can easily bring the data into Einstein Analytics by creating a new dataset; click Create ➤ Dataset button; this would be a wizard that assists you to select a source of data, with options: uploading a CSV file, using dataset builder to extract Salesforce data, and from external data source, creating recipe from existing dataset or sync connected data, and trend from a Salesforce report. In Chapter 3, we learned how to use dataflow and recipe as methods to create dataset in Einstein Analytics; it could be data from Salesforce, other data sources synced into Einstein Analytics, or from the existing dataset in Einstein Analytics. Dataflow gives you the freedom and creativity to build the dataset model needed for dashboards. Remember that sfdcRegister is the node that will create/overwrite dataset in a dataflow (including datasets created in other users Private Apps). The recipe will allow you to have a new enriched dataset easily, from two or more datasets or connected data synced to Einstein Analytics. In this chapter, we will learn everything about the dataset, from •

Dataset properties



Dataset fields



Extended metadata in dataset including field format, default fields, label, and change value



Replace and Restore dataset



Configure action for dataset

D  ataset Properties To see the properties of a dataset, find the dataset and click Edit link from arrow drop-­ down at the far right of the dataset (Figure 4-1). © Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_4

57

Chapter 4

Dataset

Figure 4-1.  Edit dataset Once the dataset properties opened, you can check and perform many things related to the dataset (Figure 4-2).

Figure 4-2.  Dataset properties The following are information that can be gathered and actions performed on the dataset:

58



Dataset label: Click the pencil icon next to the dataset name; you can change the dataset label, but not the API name.



Dataset information •

Dataset created date time



Dataset last modified date time

Chapter 4



When is dataset last refreshed



When is dataset last queried



Number of rows



Source: Which dataflow creates the dataset.



App: Where the dataset is stored; you can move it to other app by clicking the pencil icon.



Usage: All dashboards and lens that use that dataset will be listed here.



Security predicate: you can define the security predicate for that dataset.



Download and replace extended metadata file.



Replace data.



Configure actions.



Restore dataset.



Delete dataset.



Create story.



Create recipe.



Explore dataset to a lens.

Dataset

Dataset Fields When you load a CSV file as a new dataset or replace existing dataset, each column from CSV file will become a field in dataset; you will be prompted for •

Select a CSV file.



Dataset Name: CSV file name would be the default as dataset name; however, you can change the dataset name.



App: This is to define where the dataset will be stored; by default, the dataset will be stored in “My Private App.” But, you can change the app by clicking and selecting another existing app. 59

Chapter 4



Dataset

Field Type: Einstein Analytics will try to auto assign a field type (dimension, measure, or date) for each field based on the value of data; however, you can change the field type as needed, such as: all data with number are not always a measure field; it can be dimension too if they have no calculation needs like zip/postal codes in the United States.

As mentioned in previous chapters, you can monitor the data load progress from Data Manager. Once the data is loaded, open Dataset tab to find the Dataset created; if you do not see the dataset, you may need to refresh by clicking other tab or refresh the web browser. For dataset created from a dataflow, by default, the field type will follow Salesforce field type, or as defined in computeExpression node. The dataset API name is defined as Alias in sfdcRegister node, while Dataset Label Name is defined as Name in sfdcRegister node. By default, the dataset would be stored in the “Shared App,” until it is moved.

Note Alias in sfdcRegister should not contain space, while Name is allowed to have spaces.

Extended Metadata File By configuring extended metadata file, we can present data stored in the dataset differently: •

Rename field label.



Hide field.



Edit field value for dimensions field.



Format number for measures field.



Set default fields.



Specify the dataset grain label.

Now, let us see each of them, but before that, I’ll share how to edit the extended metadata easily.

60

Chapter 4

Dataset

Einstein Analytics provides an easy way to update dataset extended metadata from Analytics Studio. Open the dataset (not Edit dataset) by clicking the dataset name. This will open the dataset as a new lens. From the left panel, click “Fields” link (see Figure 4-­3).

Figure 4-3.  Click fields link to configure dataset metadata Once open, you will be presented with a list of fields categorized as the field type.

Rename Field Label To rename field label, hover over the field name with your mouse, and click the arrow at the right, and select Rename. Type in the new label, then click the Save button when done (see Figure 4-4).

61

Chapter 4

Dataset

Figure 4-4.  Rename field label

Note  Once saved, all existing labels in the dashboard or lens using this dataset will be renamed with the new label. Also note that if there is an error in one of the fields in the dataset (say, missing field that existed prior to the last run), you will not be able to save the XMD unless you delete or fix the field.

H  ide Field In a scenario that you need to hide fields that exist in the dataset but not allow users to use them in the dashboard, you can hide the fields from here. Similar with Rename, hover your mouse over the field, and select Hide (see Figure 4-­5).

62

Chapter 4

Dataset

Figure 4-5.  Hide field

Note  Once the field is set as hidden, it will impact all existing dashboards and lens; if the fields are used in the dashboards or lens, it will cause errors in the dashboard or lens.

E dit Values The purpose is to change field value, for example, instead of showing “Partner” in the Account Type, let’s change the value to “Channel.” As prior, any changes here will impact all existing dashboards and lens. You also can define the color of the selected field from here (see Figure 4-6).

Figure 4-6.  Edit field value 63

Chapter 4

Dataset

Note  If you change different two or more values into the same value, Einstein Analytics will not “combine” the data when you group it, even if the value now is the same.

F ormat Number For measures field, we can set the value shown in a certain format, such as percentage, currency, or custom format. This is very useful when you are showing the data in table format (see Figure 4-7).

Figure 4-7.  Format number

64

Chapter 4

Dataset

D  efault Fields When you click a dataset name, it will open as a new lens, and then change into table value; you will see a set of fields are displayed. By default, it would be the first five dimensions and first five measure fields that are selected in alphabetical order. You can set the defaults fields by clicking the arrow next to the dataset name (see Figure 4-8).

Figure 4-8.  Set default field

Specify the Dataset Grain Label By default, each line will be called “records.” But we can define the label of dataset grain to something else; look at sample in Figure 4-9. Count of records 0

200

300

400

Count of customers 500

600

700

800

0

Channel

100

200

300

400

500

600

700

800

286

Account Type

286

Account Type

Channel

100

Customer

715

Customer

715

Figure 4-9.  Change of grain label

65

Chapter 4

Dataset

To specify dataset grain label, click pencil icon below dataset name, and enter the label, then click Done (Figure 4-10).

Figure 4-10.  To change of grain label

Replace and Restore Dataset Einstein Analytics offers you options to replace existing dataset and restore dataset; however, you cannot back up the dataset manually online or offline. Replace dataset usually is only required when the dataset is manually loaded with a CSV file. To replace dataset, edit the dataset, and find “Replace Data” icon at the top rows of icon/button. All existing data will be replaced; however, extended metadata and security predicate defined will stay (see Figure 4-11).

66

Chapter 4

Dataset

Figure 4-11.  Replace dataset Einstein Analytics also offers you the ability to restore dataset from the last two versions, no matter if the dataset is overwritten manually using replace dataset function or overwritten after a dataflow run. This also means that Einstein Analytics automatically back ups the dataset before overwriting it. When you click Restore Dataset icon, it will show the previous versions of the dataset, when is the dataset created, and the number of rows for that version; then select which version to restore then click Restore button (Figure 4-12).

67

Chapter 4

Dataset

Figure 4-12.  Restore dataset

Configure Action for Dataset Action is useful for dataset extracted from Salesforce, whether created by dataflow or manually loaded from CSV file extracted from Salesforce, but you need to have Salesforce Id field in the dataset. The data needs to be presented in table format in a dashboard or lens, then the user is to select actions configured from a record. There are two types of actions that can be configured: 1. Open Salesforce record With this action, users can open Salesforce record from Einstein Analytics dashboard or lens; ideally, it should be in table format. 2. Perform Salesforce actions You can choose whether to show all available actions or only selected actions, such as Post, Log a Call, and so on. To configure action

68



From the dataset edit screen, click the gear icon next to Replace Data icon.



Select the field to enable for action.

Chapter 4



Select Record ID field; this field must be Salesforce record Id – this field is mandatory.



Select Display Fields; this is not mandatory; however, this is useful when you have duplicate values for the field set for action, and by adding fields here, users are able to differentiate which record they want to perform the action, we will see more in the following sample.

Dataset

In the following sample, we configure an action for Account Name field; Record ID field must be Account Id, so when the user selects the action, it will perform the action for that Account; and for Display Fields, I select Account Name, Account Type, and OwnerId. FirstName; for Actions, let us just select “Open Salesforce record” (see Figure 4-­13).

Figure 4-13.  Configure action

69

Chapter 4

Dataset

Because we select open Salesforce record action, if there is no duplicate value of Account Name, clicking the arrow next to Account Name will show “Open Record” action (Figure 4-14).

Figure 4-14.  Open record action However, if there is any duplicate value for Account Name, the system will prompt users to select which record for the action. In this sample, I select Display Fields = Account Name, Account Type, and OwnerId.FirstName; the following screenshot shows how the system will react when duplicate values exist; in this case, Account Name “Acme” exists twice in the dataset, and the user needs to select a record to open the record in Salesforce. In short, configure “Display Fields” to help the user in selecting the right record when the value is duplicated (see Figure 4-15).

Figure 4-15.  Display fields in action

70

Chapter 4

Dataset

Note  If there are no fields selected for “Display Fields,” if any duplicate found, the system will show the record Id for users to select. You can easily notice fields have been enabled for action; by hovering the mouse over the field, an arrow will appear after the field name; check out Figure 4-14 again.

S  ummary In this chapter, we discussed what can be done once the dataset is created, whether it is manually loaded from a CSV file or created from dataflow. We start with dataset properties; it shows when the dataset was created, last modified, last refreshed, last queried, the dataset usage, dataflow that created the dataset, number of records in that dataset, security predicate defined, dataset API name, and app the dataset located. Also, in dataset properties screen, we can perform multiple actions, from changing the dataset label, replacing data, configuring action, restoring dataset, deleting dataset, creating story, creating recipe, exploring dataset to a lens, downloading and replacing extended metadata file, changing app for the dataset, and defining security predicate. We also discussed how easy it is to change data and fields in the dataset with extended metadata. In the next chapter, we will discuss everything about lens, how to create lens, make use of a lens in analyzing Einstein Analytics data, using lens to download data and sharing data, and type of chart and formatting available in lens.

71

CHAPTER 5

Lens When we explored the dataset and played around with extended etadata (XMD) in Chapter 4, without our awareness, we open the dataset as a new lens. A lens is a view of a dataset; we can use it to explore the data and to get data insight. We have options to explore the data in a lens as a chart or table, including using a special query language called SAQL. Einstein Analytics provides many types of charts and table for users to explore the data, including to use conversational exploration. We will discuss all of them later in this chapter. If we compare lens with Salesforce report, there is some similarity, but not the same. When you open a dataset, it will open as a lens with one dataset (you can add other datasets from SAQL mode), while Salesforce report can contain multiple related objects, depending on the report type used. A dashboard in Salesforce requires reports as the data source, while dashboard in Einstein Analytics does not need lens as the data source but directly retrieves from the dataset. In this chapter, we will learn everything about lens including •

Einstein Analytics app



Explore dataset with chart, table, and SAQL



Explore dataset with Conversational



Clip lens to designer



Download and share data

Einstein Analytics App In this chapter, we will discuss lens; you can store a lens into an app, whether private, shared app, or public app. Let us discuss a bit on app before starting our discussion on lens.

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_5

73

Chapter 5

Lens

You may have heard “app” term earlier in the previous chapters in this book, so let us get the right term on what “app” means in Einstein Analytics. If you look at Analytics Studio user interface, between “ALL” and “DASHBOARDS” is “APPS”; so what is this app about? Apps provide containers for sets of related dashboards, lens, and datasets. Apps also control user visibility and accessibility to the items within that app, whether as manager, editor, or viewer. Einstein Analytics allows dashboard or lens to use the dataset from different apps; this may cause errors when the user opens the dashboard and unable to open the dataset stored in other apps, where the user does not have access to the app. Just to be clear, the app here has nothing to do with the mobile app.

C  reating App From Analytics Studio, click Create button, then select App. See Figure 5-1.

Figure 5-1.  Create new app Depending on your Einstein Analytics license, when creating an app, you may be asked if you want to create from Blank App or start from template. For now, let us use Create Blank App button, then enter the App name; I’ll enter “Regional Sales,” and we just have a brand-new app created. Figure 5-2 shows within an app there are dashboards, lenses, datasets, and details. Since this is a new app, we have nothing in that app yet.

74

Chapter 5

Lens

Figure 5-2.  A new app created

R  un App See Figure 5-1, at the end of the App name, for example, Shared App; notice there is a link called “Run App” at the end of the app, and this is available for all apps. Click “Run App,” or open the app and click “Run App” button; this will open lens or dashboard stored; by default it would be in the alphabetical order; however, you can edit the list to hide or reorder the list (see Figure 5-3).

Figure 5-3.  Run app and ability to Edit List

75

Chapter 5

Lens

S  hare App Sharing app in Einstein Analytics is simple; this is similar to sharing dashboard folder in Salesforce. Click the arrow at the end of the app, or open the app and click the share icon. You can share the app by user, group, or role (option to include subordinates) (see Figure 5-4).

Figure 5-4.  Give app access to other users

E xploring Dataset Once we bring the data into Einstein Analytics, normally we should verify that the data is correct, from data completeness, quantity, and quality. Completeness means the fields are complete as we expect and no missing fields; otherwise we need to re-upload the dataset or modify and rerun the dataflow. Quantity means the number of rows is complete, with no missing rows. Quality means all the field contains the right values with the correct data type.

76

Chapter 5

Lens

Using Chart in Lens From the Datasets tab, find the dataset, and click the dataset name; by default system will open the dataset as a new lens with a simple chart (see Figure 5-5) and contain the following setup: •

Bar chart.



Bar length is the count of rows.



No grouping.



No filters.

Figure 5-5.  New lens With this simple chart, we can verify the data quantity, and from the chart, we can see the dataset have 1K of rows; we can verify this from dataset properties too (see Figure 5-5) and look for “Count of Rows.” However, with this chart, we still cannot verify if the dataset contains complete fields, field type, and value of fields; we can change to table mode and select Values Table to verify those items.

77

Chapter 5

Lens

Before we discussed table mode, let us explore common things we can do in chart mode and analyze data using chart mode (see Figure 5-6): •

Change bar length to Sum, Average, Maximum, Minimum, Unique, Median, First, Last, Stddev, Stddevp, Var, and Varp. All of them are only applicable for measures field, with exception of Unique which can be used for any field. I am not going to explain each of the functions, but it is good to familiarize each of them.



Add additional bar length: With this you can analyze multiple measurements, such as count of rows and sum of annual of revenue.



Add bars: This means that we are going to have new grouping in the chart.



Add filters: We can add multiple filters for multiple fields, but a field only can be defined once. We can can apply filter logic OR and AND.



Change chart type: Einstein Analytics offers more than 30 chart types for us to use, but remember each chart type has its own properties, so your existing selection may be removed if the new chart does not have such properties or move as other properties. If you are confused which is the best chart suited, click “Suggested Chart” to let Einstein Analytics suggest a few options based on the data and selection.



Apply chart formatting: You can set chart title, font size, show axis, show legend, and so on.

Figure 5-6.  Analyze data with chart 78

Chapter 5

Lens

Using Table in Lens Let us switch to the table mode by clicking the “Chart Mode” icon, then select “Values Table” (see Figure 5-7).

Figure 5-7.  Switch to Values Table If you remember in Chapter 4, we discussed that we can set default fields for a dataset using extended metadata. If default fields for the dataset have been configured, switching to table mode will give us those default fields as table columns. Actions configured in extended metadata will be applied too in table mode, from rename field label, edit values, and format number. Here are a few things you can configure on the table (see Figure 5-8): •

At the bottom of the left panel, look for Query Limit; by default it will show 100 rows only; you can edit to set the query limit up to 10,000 rows.



Add or remove fields easily by clicking the pencil icon at the left panel; you can also reorder fields by dragging and dropping the fields accordingly.



Click the formatting (paint) icon at the right to format the table with spacing, color, header, and so on.



Click the table header to sort the table ascending or descending by a specific field.

79

Chapter 5

Lens

Figure 5-8.  Values Table Using Values Table, we will able to verify if the dataset contains all fields that we need to build a dashboard and if all fields contain correct values. We cannot verify that in chart mode; however, chart mode allows you to group data and sort it easily, so we can easily analyze the data on the fly, or get percentage of each group, or to get data trend over a timeline.

S  aving Lens After dataset opens as a new lens, hit save (floppy disk) icon on the top right corner to save the lens configured, so you can reuse the lens in the future. You can store it into “My Private App” if you do not want anyone else to touch it, or to a public app if need to share with your team or other users. Enter the lens title and optional for description. When you save a lens, the table or chart, including all the filters, fields, grouping, sorting, and formatting, will be stored accordingly for future usage. If you have edited the chart or table with SAQL, it will be stored too. When opening a lens and saving it to a different app, Einstein Analytics will move the app to the new app, so it is not a Save As. If you need to clone the lens, click … icon at the topright of the screen, then click Clone in New Tab (see Figure 5-9). 80

Chapter 5

Lens

Figure 5-9.  Clone lens

P  resent Lens Next to Save icon is Present icon, the purpose of this button is to show the lens in the web browser full screen. Press Esc key to exit from full-screen mode. You can also use just the letter p to enter and exit the presentation mode. This is usually useful when you need to present the lens to the audience and not disturb by other things, or when you need to analyze the dataset with more real estate.

E xplore with Conversational When you explore lens with chart mode or table mode, you may notice there is a text box above the chart or table with the following sentences “What do you want to see? Just start typing…” . If you do not see this box, make sure Conversational Exploration has been enabled. Navigate to the Setup menu, type Analytics in Quick Find textbox, then click Settings (see Figure 5-10).

81

Chapter 5

Lens

Figure 5-10.  Enable conversational exploration Let’s go back to the lens; if you save it earlier, click Lenses tab, and the lens should appear at the top.

Note  In Lenses tab, notice the last column “Data Refreshed”; this tells us when the dataset last refreshed, and this date time is similar with “Data Refreshed” in the Dataset tab. Conversational exploration means to ask questions on the dataset using nontechnical language and get a quick answer as a chart. This is useful when you need to analyze dataset quickly. How could we interact with the dataset with this method? See Figure 5-11; click the text box, and Einstein will show you a few suggestions on what you can ask. A conversation can begin with “show me,” “what is,” or begin with a dimension like “industry,” begin with a measure like “amount,” “top x,” and so on. You even can include filters in the conversation to narrow the result area. 82

Chapter 5

Lens

Here are a few sample questions you can ask based on fields in the dataset: •

Top 2 annual revenue by account type



Show count of rows by account type



Show me sum annual revenue by owner id



Show me avg employees by account type



What is annual revenue for previous year

Ideally, the question should contain a measure field for Einstein Analytics to build the chart. All parameters or filters will be automatically entered based on the questions, and you also will be able to modify the parameters and filters manually as needed (see Figure 5-11).

Figure 5-11.  Converse with data in lens

Clip Lens to Designer An icon next to Present with scissors icon is called Clip to Designer. The purpose of this function is to add the lens into a dashboard. Einstein Analytics will add the lens as a step to currently open dashboards. If there is no dashboard opened, Einstein Analytics will create a new dashboard, then add the lens as a step to the new dashboard created. 83

Chapter 5

Lens

When clicking this icon, Einstein Analytics will ask for a label (you can leave it blank, and a default name will be provided in the dashboard), then click Clip to Designer button to apply. Notice that Clip to Designer will not add chart or table widget to the dashboard; you need to drag the step into dashboard designer to have it as a widget in the dashboard. Furthermore, you can change the chart type or formatting in the dashboard (see Figure 5-12).

Figure 5-12.  Clip a lens to a new dashboard Once a lens is clipped to a dashboard, the lens is copied to the dashboard; this means that the step created in the dashboard does not relate to the original lens, and they are completely independent. Any changes to the original lens will not impact to the dashboard, and any changes in the dashboard widget will not impact the lens too. We will discuss dashboard in Chapter 6, so you need not worry about it for now.

Sharing and Downloading Lens Sharing lens to your team or the whole company is easy, as discussed in Chapter 1; the permission to access the content of an “app” is controlled in the app, including lens and other contents such as dataset and dashboard. So, before sharing a lens, make sure the lens is stored in the app accessible by the users and dataset used for that lens also stored in an app accessible by the users.

84

Chapter 5

Lens

Note  You can have lens and dataset stored in the different apps.

G  et URL Instead to manually copy and paste the URL to your colleague, click … icon, then select Share. Click Get URL tab, and you will be presented with two options; open the link in Analytics Tab or Analytics Studio. So, which one should we use? Ideally, if your colleague needs to edit the lens, select URL for Analytics Studio, but if just to explore the lens, select URL for Analytics Tab (see Figure 5-13).

Figure 5-13.  Get URL to share a lens

P  ost to Feed With this feature, you can easily share the lens to a user chatter feed or a group chatter feed. This will post the chart or table as an image and visible to all users in the group or a user feed. Even for users who do not have Einstein Analytics license, they will be able to see the image posted as a feed.

85

Chapter 5

Lens

Download Probably you have a question on how to download data from the dataset? The answer is that Einstein Analytics does not give options to download data to directly from dataset to Excel or CSV file. But, when you explore the dataset into a table, you can download the dataset into Excel or CSV file; make sure all the fields you want to download are added to the table. If you notice, I mentioned fields added to the table; this means that you should not use chart lens if would like to download the raw data. Download from chart lens will only give you a summary number based on the chart that has been configured. Einstein Analytics also gives you the option to download the lens as an image; the image will be in PNG format, similar to the one in Post to Feed. Tips: If you do not see Download option, check with your Salesforce admin to enable “Download Analytics Data” permission on your Einstein Analytics permission set.

Summary In this chapter, we discussed everything about lens. Usually, we use lens to explore a dataset, both from dataset and from a widget in dashboard. So far, we have not discussed dashboard, but in the next chapter, we will build a dashboard from scratch. We learned hands-on how to explore the dataset into a new lens, including both chart mode and table mode, then we shared about saving lens, and clone lens. We also discussed how to explore lens with conversational language, so instead of manually entering fields and grouping, the system will do the job for us; we just need to enter the human-friendly language. Clip lens to designer offers to copy lens built into an existing dashboard or to a new dashboard; here we also mentioned that lens is not related to a dashboard; anything added to the dashboard will not impact the lens or dashboard anymore; they are completely independent, just sharing the same dataset. We end the chapter on how to share lens to your team or the whole company; we also can post lens chart or table into someone chatter feed or group feed, and with lens, we are able to download raw data from Einstein Analytics.

86

CHAPTER 6

Building the Dashboard After discussing dataflow, dataset, and lens in previous chapters, we are going to start building a dashboard in this chapter. We will start with permissions, layouts, dashboard templates, widgets, steps, pages, facets, and using multiple datasets in a dashboard; we should use most of those items when building a dashboard, but probably not all of them in a dashboard; it is not a must to use template, or to have multiple pages, or to use multiple datasets in a dashboard. What can we expect from a dashboard in Einstein Analytics? With Einstein Analytics, we can build a dashboard that shows numerous key metrics for our business, from sales, support, marketing, adoption, and so on. When building a dashboard, you can easily add dashboard filters using any fields available in the dataset, so you will be able to analyze data, including the use of widget faceting and brodcasting. For users on the road, Einstein Analytics also comes with mobile app that can be downloaded from App Store or Google Play Store. By default, all dashboards built will work in the mobile app; however, the layout is not optimized for mobile, until you create a layout optimized for mobile. In this chapter, we will learn the following topics related to creating dashboard: •

Permission



Layout



Template



Widgets



Steps



Pages



Faceting and global filter



Using multiple datasets

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_6

87

Chapter 6

Building the Dashboard

P  ermission We discussed “app” in Chapter 1, “app” controlled user permission in accessing items within that app, whether as a viewer or editor or manager. Only users with editor or manager access (defined in the app) will be able to store dashboard into that app; otherwise, they will not able to store the dashboard to that app. On top of permissions in the app, users also need to have Create and Edit Analytics Dashboards permission assigned in the Salesforce permission set to create dashboards. Depending on your Salesforce admin setup, it could be a standard or custom permission set.

L ayout When we create a new dashboard, the default layout is called “Default,” and it is optimized only for viewing the dashboard with a web browser from a computer, not from the mobile app. You can have multiple layouts for a dashboard that are optimized for web browser, tablet, and mobile. Let’s start creating a new dashboard using a dataset prepared in Chapter 4. 1. Log in to Salesforce, and open Analytics Studio. 2. Click the “Create” button, then select “Dashboard.” 3. Select “Create Blank Dashboard”; this will bring you to Dashboard Designer with a blank canvas. 4. By default, a new dashboard designer will have 12 columns, see layout panel at the right, notice there are multiple properties, and start from general, device, and background image. If you can’t find layout panel, click the gear icon below dashboard name; check out Figure 6-1.

88

Chapter 6

Building the Dashboard

Figure 6-1.  Dashboard designer without widgets 5. From this panel, we can change the layout name and other layout properties like column, row height, cell spacing, background color, and so on. Let us change the layout name from Default to “Web Browser” and Columns to 18. Notice that the label next to the filter icon is also changed to web browser. 6. Next to the gear icon, there is + icon and untitled tab with an arrow. When you create a dashboard, it will start with one page only, and the page name as “Untitled”; we can rename this by clicking the arrow and selecting Rename; other options are hide from navigation, clone, and delete. For now, let us rename the page name to “Page-­1”. 7. Dashboard in Einstein Analytics can be up to 20 multiple pages; click + icon to create a new page, and enter the name; for now, let’s stick with one page. We’ll discuss multiple pages dashboard later in this chapter. 8. Let us also rename the dashboard name from “New dashboard” to “Global Accounts”; click the pencil icon next to “New dashboard” to change the dashboard name. See what we have now as in Figure 6-2. 89

Chapter 6

Building the Dashboard

Figure 6-2.  Change in layout name, columns, page name, and dashboard name 9. To manage layouts, click arrow for layout (next to filter icon); in our case, it is called “Web Browser” now, then click Manage Layouts. From here, we can see the current layout selected; add new layout (select layout template and enter layout name), or delete existing layouts. You cannot delete the current used layout, and you need one layout set as current (see Figure 6-3).

90

Chapter 6

Building the Dashboard

Figure 6-3.  Manage layouts to see the current layout, add and delete layout 10. If you create a layout using phone template, this template will be auto-selected when the user opens the dashboard from the mobile app. For now, we will not generate a new layout; when we generate a new layout, all existing widgets will be copied from the current layout to the new layout. 11. Let us save the dashboard by clicking Save icon at the top right corner; name the dashboard title as “Global Accounts,” and store it to “My Private App.”

Template When you create a new dashboard, Einstein Analytics will ask if you would like to create from a blank dashboard or using a dashboard template. If you select to create a dashboard from a template, you can choose from nine templates provided: •

Comparison Dashboard



Details Dashboard



Metric Trend 91

Chapter 6

Building the Dashboard



Performance Summary



Summary Dashboard



Table Expansion



Three-Columns Dashboard



Tile Dashboard



Time Series

Using dashboard template, you can speed up development process in creating a new dashboard. The new dashboard will come with widgets and layouts based on the selected template but also give you the flexibility to move, add, and delete widgets too. Some templates come with filter, container, main chart, supporting charts, table, and key metrics. While some of them such as Metric Trend, Performance Summary, Table Expansion, and Time Series will ask you a few questions, each of this template will ask for different questions, but dataset will always be asked; check out Table 6-1 for the matrix between dashboard template with questions.

Table 6-1.  Questions for Dashboard Template Metric Trend Performance Summary Table Expansion

Time Series

Choose a dataset









Choose a metric





Choose a date









Choose groupings



Choose dimensions





Choose measures





Choose filters



Choose a confidence interval



Indicate if seasonality impacts your data



92

Chapter 6

Building the Dashboard

Some of the templates are also marked as “smart”; this means the dashboard requires little to no additional configuration; example for Time Series template, the dashboard visualizes how metrics change over time and predicts future metrics trends based on historical data. We will not discuss each template in this book, but let us hands-on to create a new dashboard using Time Series template: 1. Log in to Salesforce, and open Analytics Studio. 2. Click the “Create” button, then select “Dashboard.” 3. Select “Create Dashboard from Template.” 4. Select “Time Series” template; click Continue button. 5. You need to select a dataset and fields for a few questions, then click “Looks good, next” (see Figure 6-4).

Figure 6-4.  Create dashboard with Time Series template 6. Enter dashboard name as “Time Series,” and store it to “Shared App.”

93

Chapter 6

Building the Dashboard

7. Time Series dashboard is now created with filters, timeline as main chart, supporting charts, links, and table added to the dashboard based on fields selected in previous screen. The timeline chart also predicts future metrics based on historical data (see Figure 6-5).

Figure 6-5.  A Time Series dashboard

W  idgets When you create a new blank dashboard, you will get only 12 columns box and a list of icons on the left panel; see the blank dashboard created earlier for “Global Accounts” as in Figure 6-2. Each of the icons can be dragged to the dashboard designer for different usage; let us walk through each of them and how can we use them. Each items added to the dashboard designer is called as “widget.”

94

Chapter 6

Building the Dashboard

C  hart This should be the most commonly used widgets in every dashboard; use the chart widget to show data as a chart in the dashboard. There are more than 30 types of charts provided by Einstein Analytics. Let us do a quick hand on to use this widget: 1. Open Global Accounts dashboard created earlier. 2. Drag chart widget to the dashboard designer. 3. Click the “Chart” icon in the widget. 4. You will be asked to select a dataset. Once a dataset selected, by default you will get •

Bar chart



Bar length is count of rows



Without filter



Without grouping

This looks similar when we explore dataset by creating a new lens, with the difference at the top left corner “Untitled Step”, and additional Back and Done button at the bottom. 5. Change “Untitled Step” to “Step No of Rows.” 6. Click the Done button and Save icon to save the dashboard. 7. Notice the step created at the right panel of dashboard designer, and it shows all steps created for the dashboard; we also can create step manually from there. We’ll discuss “step” later in this chapter. See what we have now as in Figure 6-6.

95

Chapter 6

Building the Dashboard

Figure 6-6.  Blank dashboard with a widget and step

Table Use this widget to display record detail data in the dashboard. Similar with the chart widget, let us continue the Global Accounts dashboard: 1. Assume Global Accounts dashboard has been opened; if not, open it and switch to edit mode by click pencil icon at top right. 2. Drag the table icon into dashboard designer, below the chart widget. 3. Click the “table” icon in the widget created. You may notice that the system no longer asks you to provide a dataset; this is because Einstein Analytics remembers that you have selected a dataset previously, so the same dataset will be used; however, if you need to select a different dataset, click “Back” button. 4. Even if this is a table widget, by default, we’ll get a bar chart with a count of the number of rows; if you do not change the chart to table mode, you will get number of rows only in the table. To get record detail in the table, let us change into the table by selecting table mode then Values Table. 5. Select fields that we would like to show in the dashboard. 96

Chapter 6

Building the Dashboard

6. Change the step title to “Step Record Detail”. 7. Click the Done button. 8. To get better visibility of the table content, you can move and resize the widget size accordingly. 9. Click the Save icon. Now our dashboard should looks similar as Figure 6-7.

Figure 6-7.  Blank dashboard with a widget and step

Tips To have columns occupy the whole table width, go to the widget properties, find the Spacing section, then set Column Width = Fit to Widget; with this setting, the width of the columns will be auto adjusted when the web browser size changes.

F ilter Use this widget to make a global filter of the data display in the dashboard. You can select to have a single filter or global filters. Hands-on to use this widget: 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag filter icon into dashboard designer, below table widget.

97

Chapter 6

Building the Dashboard

3. By default, single global filter is selected. 4. Click the “Filter” icon in the widget. 5. Select a dataset, then select a field from the selected dataset. 6. Click the “Create” button. 7. Click “Preview” (eye) icon at the top right to test if the filter added is working properly; notice the dashboard is no longer in edit mode (no blocks in the background). See Figure 6-8. 8. To edit the dashboard again, click the pencil icon next to save icon. 9. Click save icon.

Figure 6-8.  Dashboard with global filter

98

Chapter 6

Building the Dashboard

Tips In edit mode, you can simply hit “e” to switch to preview mode and hit “e” again to go back to edit mode. Hit “s” key to save the dashboard.

C  ontainer This widget is useful to group a few widgets into a container; so you can move them easily, and you also can set the color to group multiple widgets with the same purpose. 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag container widget to dashboard designer. 3. Make it wider and occupy the whole width of the dashboard. 4. Drag both chart and table created into the container. 5. Change the container widget background color to green; you can do this by selecting container widget, then look for widget style at the right panel, click the arrow under background color, and select green color. 6. Hit “e” then “s” key to exit from edit mode, then save the dashboard. The result should be similar with Figure 6-9.

Figure 6-9.  Dashboard with container

99

Chapter 6

Building the Dashboard

D  ate Use this widget to add date field as a filter. You can only use the date field for this widget: 1. Drag date widget to the dashboard designer. 2. Click the “Date” icon in the widget. 3. Select a date field as a filter; only date fields will be shown here. 4. Click the “Create” button. 5. Select the widget, and look for widget properties at the right of the window. 6. Change widget title, and enable “Update instantly.” 7. Click Step tab; few things to notice are as folows: •

Apply global filter: Enable this to implement value selected in the global filter widget discussed earlier.



Apply filter from faceting: If this is enabled, when the user selects a chart for a group and broadcast to other widgets, this will filter available date based on that selection.



Selection type: To configure if the selection is required as single or multiple selections.



Broadcast selection as facets: When the user selects a period (range) of dates, this selection will broadcast to other widgets; this is related to “Apply filter from faceting.”

For now, let us not change abovementioned; just use the default values. 8. Move and resize the widget accordingly; I’ll move this widget to the top right of the container created earlier and move chart and table widget below the date widget. 9. Click Preview icon (or hit “e” key) to verify the Date filter is working correctly. 10. Hit “e” then “s” key to exit preview mode, then save the dashboard. The result should be similar with Figure 6-10. 100

Chapter 6

Building the Dashboard

Figure 6-10.  Dashboard with Date filter

L inks Use this widget to navigate the user to •

Saved lens: Defined a saved lens



Saved dashboard: Defined a saved dashboard



New lens: Defined an existing step using in dashboard



URL: Open any URL into a new tab



Page in layout: Only available if there are multiple pages in the dashboard

Even the widget name is linked, it will appear as a button in the dashboard. Hands-­ on exercise 1. Continue Global Accounts dashboard. 2. Drag links widget to the container and drop it at top right corner. 3. Change the Text to “Search with Google.” 4. Set “Link To” to URL. 5. Destination: http://www.google.com

101

Chapter 6

Building the Dashboard

6. Link Tooltip: “Click to open Google.” 7. Hit “e” then “s” key. 8. Clicking the button “Search with Google” should open Google web site in a new tab in the web browser. The result should be similar with Figure 6-11.

Figure 6-11.  Dashboard link at top right

Tips To get round corners for the link button, click the widget; from the widget properties, look for widget style section, then set the border radius to 8 or 16. You also can change the background color and border color.

I mage As the widget name suggests, the usage of this widget is to add an image to the dashboard. It can be for logo or other images to be embedded to the dashboard. Hands-­ on 1. Open Global Accounts dashboard, and switch to edit mode. 2. Move date widget to the right, so we will have space at the top left corner for image widget. 3. Drag image logo to the top left inside the container widget.

102

Chapter 6

Building the Dashboard

4. Click the Image icon within the widget. 5. Click Browse Files icon, and select the image for a logo, image format supported gif, bmp, jpeg, jpg, png, and svg. 6. From widget properties, change image scale to fit width or fit height; arrange image alignment, and you also can resize the widget. 7. Hit “e” then “s” key. The result should be similar with Figure 6-12.

Figure 6-12.  Adding image to the dashboard

L ist List widget is another most commonly used widget; the purpose of this widget is to filter data shown in the chart or table. List values will be automatically populated as a unique value from a selected field. Hands-on 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag list widget after Date widget. 3. Resize the widget height to occupy two blocks. 4. Click List icon in the widget. 5. Select a field – I will choose Account Type – and click Create button. 6. Hit “e” then “s” key. 103

Chapter 6

Building the Dashboard

7. Click Type drop-down; in my case, I see three radio buttons with number at the right – for radio button, you only can select one value, and the number at the right means number of records for each value. The result should be similar with Figure 6-13.

Figure 6-13.  Adding list widget 8. Let us edit the dashboard; in the list widget, click Step tab, and change selection type to “Multiple selections”; now the radio button changed to check box, where you can select multiple values.

N  umber In some cases, you would like to show number in the dashboard; this is good to catch user attention, such as Total Amount, or Number of Open Case, and so on. Hands-on 1. Open Global Accounts dashboard, and switch to edit mode. 2. Resize the container to be bigger, and move the table to the bottom and chart to the right, so we’ll have space under the logo. 3. Drag number widget below the logo. 4. Resize the widget height to occupy three blocks. 5. Click Number icon in the widget. 6. Let’s use default value, which is count of rows; click Done button.

104

Chapter 6

Building the Dashboard

7. In widget properties, look for Text Style section, change number size to 48, and change alignment to center. 8. Hit “e” then “s” key. The result should be similar with Figure 6-14.

Figure 6-14.  Adding list widget

R  ange Use this widget and link it to a measure field to filter dashboard data. This widget allows users to filter data by entering from and to value, or slide the slider provided and the number will be adjusted as the user adjusts the slider: 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag range widget to an empty space in dashboard designer. 3. Click Range icon in the widget. 4. Select a measure field; click the Create button. 5. Hit “e” then “s” key. The result should be similar with Figure 6-15.

105

Chapter 6

Building the Dashboard

Figure 6-15.  Adding range widget

T ext In many cases, we need to inform the user about charts added into the dashboard; use a Text widget to add that information as a label. We also can use this widget to inform the dashboard in general, including as dashboard title. Apply text style and widget style to make the widget attractive: 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag Text widget to an empty space in dashboard designer. 3. Look at widget properties at the right panel; modify the Text to Global Accounts. 4. Click the Text Style panel, and change the color to red. 5. You will notice the changes at dashboard designer as you work. 6. Hit “e” then “s” key. The result should be similar with Figure 6-16.

106

Chapter 6

Building the Dashboard

Figure 6-16.  Adding Text widget as dashboard title

T oggle Adding the toggle widget to allow users to filter data easily with one click. Similar with “List” widget, when you link this widget to a field from dataset, it will auto show each unique values from the field, but if the value does not exist, it will be not shown at all. If we need to show all possible values, we can use “static step” to handle this; we will discuss a static step in the last chapter: 1. Open Global Accounts dashboard, and switch to edit mode. 2. Drag toggle widget to an empty space in dashboard designer. 3. Click Toggle icon in the widget. 4. Select a field to use for the toggle. 5. Click Create button to continue. 6. Adjust the widget size as necessary; ideally make all values visible; otherwise, the user needs to scroll. 7. Click Step tab, and change selection type to “Multiple selections”; this is to allow the user to select multiple values. 8. Hit “e” then “s” key. Figure 6-17 shows a toggle with two values selected (background in blue). 107

Chapter 6

Building the Dashboard

Figure 6-17.  Adding Text widget as dashboard title

N  avigation Before adding this widget, let us add a new page to the dashboard. Remember that we can have multiple pages in a dashboard? We will discuss pages in the next section: 1. Open Global Accounts dashboard, and switch to edit mode 2. Click + icon at the top left next to the gear icon 3. Enter page name, enter “Page-2”, and click Add button. 4. Now we have a blank dashboard designer, and Page-2 tab is selected (see Figure 6-­18).

Figure 6-18.  Adding Text widget as dashboard title 108

Chapter 6

Building the Dashboard

5. Click Page-1 tab; now you will see all widgets added previously. 6. Drag Navigation widget to the dashboard designer. 7. By default, it will show page-1 and page-2 as available page; you can add color and style to the widget. 8. Step 6 will add Navigation widget to page-1 only, not page-2, so select the widget added, at the bottom right.

a. Select “Add to Page.”



b. Click “Page-2.”



c. Click the “Apply” button. 9. Now the widget is copied to page-2. 10. Hit “e” then “s” key. Play around by navigating to page-2 and back to page-1. See Figure 6-19.

Figure 6-19.  Dashboard with Navigation widget added at the bottom

109

Chapter 6

Building the Dashboard

P  age As mentioned earlier, a dashboard can have multiple pages. For admin, this is good in terms of maintaining dashboards; instead of having many dashboards in Analytics Studio, dashboard with multiple pages will be shown only as one dashboard. From the user perspective, this offers better experience as the user will not open the wrong dashboard, such as if we have a “main” dashboard with multiple supporting dashboards. We can use link widget to link dashboards, but it may cause confusion; every time the user opens a new link, it will open a new tab, and the user will end up having a lot of tabs opened. However, it depends on the needs; sometimes we must use multiple dashboards, instead of one dashboard with multiple pages. We will go through each use case in this chapter, when we should use multiple pages in a dashboard, and when we should use multiple dashboards. We will have no hands-on in this section, but you can refer to hands-on at Figures 6-18 and 6-19 when we discussed Navigation widget.

S  haring Widget Multi-pages dashboard offers the ability to share widgets across pages. When you add a widget to other pages, they will share the same widget style, meaning changing the widget style in a page will impact the widget style shown in other pages; however, moving the widget in a page will not impact the location of the widget in other pages. Einstein Analytics also allows us to unlink the widget from other pages; select the widget, click the top right, above widget, and Step tab to unlink it (see Figure 6-20). Please note that range and date widgets cannot be shared.

110

Chapter 6

Building the Dashboard

Figure 6-20.  Unlink widget used in multiple pages

Dataset Filter When you use one dataset across multiple pages and there are filters added, the filter selected in one page will also filter the result in other pages; this includes faceting from chart too. If you totally need to separate them, you must use multiple dashboards, not a dashboard with multiple pages.

Dashboard tab One of the benefits using multiple pages is transparency for users; the user will not know if they have multiple pages open, because the tab and URL are not changed. Using the link widget will open the new dashboard into new tabs, so there will be multiple tabs open.

Performance Because the dataset has been loaded when opening the first dashboard, dashboards with multiple pages will offer better performance compared to opening multiple dashboards; this is also because the steps spread across pages.

111

Chapter 6

Building the Dashboard

A  doption and Maintenance Using a dashboard with multiple pages will easily allow admin to monitor the usage and adoption of a dashboard. Using Event Monitoring (it is another product from Salesforce), the admin just needs to monitor a dashboard instead of monitoring multiple dashboards. Dashboard with multiple pages will only show once in the Analytics Studio; this is cleaner in maintaining overall dashboards.

F aceting Faceting is one of the most useful features in Einstein Analytics for a user in analyzing data. Faceting is enabled by default when a widget added. When the user selects a widget, other widgets using the same dataset or have connected data source will be filtered based on the selection on a widget, for example, selecting a product in widget will filter the dataset to the specific product selected, so other widgets using the same dataset will be automatically filtered. Let’s go back to the Global Accounts dashboard created earlier, edit the dashboard, click a chart, then click Step tab. Notice there are two check boxes related to faceting: 1) Apply filters from faceting 2) Broadcast selections as facets Both options are enabled by default. The first option is to accept filter from the other widget that broadcast faceting, and the second option is to broadcast selection as facets to other widgets, so if other widgets have “Apply filters from faceting” enabled, their data will be filtered based on the selection in the selected widget (see Figure 6-21). We can have more than one widget broadcast facet, and the dataset will be filtered by all selections, for example, product is A and region is the United States, and you also can select more than one selection in a widget (change chart widget selection type to “Multiple selection”).

112

Chapter 6

Building the Dashboard

Figure 6-21.  Faceting options in widget step

G  lobal Filter When you need to use partial data from a dataset based on some criteria, adding global filter is the easiest option rather than recreating a new dataset using dataflow or recipe, which will give the admin another item to maintain. It will save us number of rows used by Einstein Analytics as we did not create a new dataset. Another benefit: using global filter will not slow down the dashboard performance. To achieve partial data usage, we should make the filter locked, so our users will see only data applicable for the dashboard, for example, we need to build a customer dashboard, but our dataset is combined between customer and prospect, so we can add a eglobal filter to filter only customers, then lock the filter. Start with adding the filter widget, click “Filter” icon in the widget, select the dataset, then field will be used as filter. Click … (ellipsis) icon, then select “Pick Initial Values”; click the filter widget, and select the values you want to include, exclude, or contain; click “Apply” button to continue. Next, click “Manage Global Filters” button, click pencil icon next to the field you want to lock, then enable “Locked” and click “Apply” button again. When a dashboard is added with global filters, you will notice filter icon appear at the top bar, next to manage layout drop-down; it will also tell you how many global filters have been added. You can add multiple filters into global filters (see Figure 6-22). 113

Chapter 6

Building the Dashboard

Figure 6-22.  Dashboard with global filter and filter properties

Using Multiple Dataset So far, we have discussed to use one dataset in a filter; however, we can use multiple datasets in a dashboard. When you add the widget from a different dataset, filtering and faceting will not work for widgets using different dataset. However, we can link them using a common value, for example, we have a dataset called order for actual sales and another dataset called target, so when we select a sales rep name from a widget, we would like to show target only for the selected sales rep; in this case, we will use User Name to connect both datasets (ideally it should be User Id, as User Name can be duplicated). Let’s have a quick hands-on for this exercise: 1. Prepare the data for a new dataset, for this I’ll sample use Microsoft Excel.

114

Chapter 6

Building the Dashboard

Table 6-2.  Target Dataset Sales Rep

Target Customer

Johan GS0

10

Jack GS0

3

2. Create new dataset using CSV file upload. 3. Open Global Accounts dashboard, and switch to edit mode. 4. Drag a chart widget to dashboard designer. 5. Click the “Chart” icon in the widget. 6. By default, it will auto select the last dataset used; since we are going to use a new dataset, click Back button. 7. Select target dataset just created. 8. Select a field for grouping; for this scenario, select sales rep, and change bar length to “Sum of Target Customer.” 9. Click Done button (see Figure 6-23).

Figure 6-23.  Dashboard with two datasets

115

Chapter 6

Building the Dashboard

10. To relate the dataset, click … (ellipsis) button at the top right corner, and select Connect Data Sources. 11. Click New Connection button. 12. Enter Connection Name = Sales Rep; and select a field for both data source: Data Source 1, owner from Account owner dataset; Data Source 2, sales rep name from the target dataset (see Figure 6-24).

Figure 6-24.  Build data sources connection 13. Click Save button then Close button. 14. Done and now let us try. 15. Exit from edit mode by hitting “e” key. 16. When selecting a name from the Account owner widget, the target values will be selected, and the same when selecting a name from the target widget, Account owner value will be filtered accordingly with faceting. We have discussed faceting and broadcast in this chapter earlier. Wes should have end dashboard similar with Figure 6-25. 116

Chapter 6

Building the Dashboard

Figure 6-25.  Dashboard with two connected datasets

Summary In this chapter, we discussed everything a dashboard builder needs to know to build a dashboard from scratch in Einstein Analytics. We start with the permissions needed for the user to build a dashboard. Layout and template are something that a dashboard builder should know to fully make use in building a good dashboard. We discussed all widgets available in Einstein Analytics, including hands-on exercise for most of the widgets. Then, we look into building dashboard with multiple pages; we explained the benefits of using multi-pages in a dashboard and when we should not use multiple pages dashboard. We discussed how faceting works across widgets; faceting is one of the most frequently used features in analyzing data in the dashboard. Then we share using global filters in a dashboard. With global filters, we can use only a partial data of the dataset and lock it according to the dashboard purpose. We end with hands-on to use and connect multiple datasets in a dashboard. In the next chapter, we’ll discuss how to explore and make use of dashboard in analyzing data.

117

CHAPTER 7

Exploring the Dashboard If you come from Salesforce background, Einstein Analytics offers a more interactive dashboard with better performance compared to Salesforce standard dashboard. Faceting in Einstein Analytics dashboard offers users a better experience to analyze, and drilling down data is much easier. In addition to charts widget, adding a table widget into the dashboard to show record-level details is very useful for users in exploring data. Data in the table will automatically be filtered when selection is made on the charts. Users can make a selection on multiple charts. This will filter the whole dashboard further; you also can configure the chart to enable on multiple selections. When users select multiple charts, by default, it will broadcast to filter other widgets. “AND” is the filter logic for multiple charts selection, while “OR” is the filter logic when the user selects multiple selections in an individual chart. We will see the sample later in this chapter. Before exploring dashboards, as admin, we will look into how to inspect a dashboard for better performance; this will include detailed information for each step in the dashboard and advise to improve dashboard performance. In this chapter, we will learn the following topics: •

Dashboard Inspector



Set notification on the widget



Make annotation on the dashboard



Sharing widget



Embed dashboard to Lightning page

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_7

119

Chapter 7

Exploring the Dashboard

D  ashboard Inspector Once a dashboard is built, ideally a dashboard builder should evaluate if the dashboard is designed for the optimal performance. The good thing is that Einstein Analytics comes with this feature; it is called “Dashboard Inspector.” Let’s have a quick hands-on for this: 1. Open Analytics Studio, and open Global Accounts dashboard built in the previous chapter. 2. Click … (ellipsis) button at the top right corner. 3. Select “Dashboard Inspector.” 4. You will notice two tabs in the Dashboard Inspector, which are Steps and Performance (see Figure 7-1). 5. At the Steps tab, there will be four columns:

a. Step: All steps added to the dashboard will be shown here.



b. # Runs: How many times the step has been run; we can keep the panel open when exploring the dashboard.



c. First (ms): Time needed for initial step run.



d. Max (ms): Max time needed to run the step. 6. You can sort the table by clicking the header. Select a step, and you will get more info about the step; the value will be updated when you explore the dashboard.



a. Datasets: Dataset name and when was the data last refreshed.



b. Filters: All filters that impacted that step, including global filters.



c. Dimensions: All fields used related to the step.



d. Measures: All fields used and the aggregation, such as sum, count, and so on.



e. Last run metrics (ms), including metadata, waiting, and query in milliseconds.

120

Chapter 7

Exploring the Dashboard

This is the same by selecting “Show Details” from a widget. Additionally, there are two more icons at the right: •

View performance details: This will tell the dashboard builder if any data manipulation was not optimal.



View more details: Use this feature if you would need to debug the step which contains



Original Query



Final Query



Result

In this window, we see how compact form query is translated into SAQL, and what is the result from the query.

Figure 7-1.  Analyze step with Dashboard Inspector 121

Chapter 7

Exploring the Dashboard

7. Select the “Performance” tab; click “Run Performance Check.” 8. In a few seconds, you should get the result. This will tell you

a. Initial load time



b. Initial # of queries



c. Performance factors: This will tell us if we have too many steps in the dashboard, steps that fire multiple queries, and redundant steps. With this info, we can fix the step to improve dashboard performance.

S  et Notifications This function is useful for users to get notification from Einstein Analytics widget when certain criteria are met. With notifications, you can get Einstein Analytics work for you, select a widget and define the criteria, set if the notification should notify you only once, or always, then set the schedule for notification to run. Each user can set up to ten notifications, because of this limit, you should set notifications only for items important to you and delete notifications no longer valid. You can see the notifications in Analytics Studio, Lightning Experience notification, Analytics mobile app for iOS, and e-mail; see Figure 7-4 for sample of notification in Lightning experience. You can set notification from chart, table, and number widget. Make sure “Show widget actions” is enabled for the widget; otherwise, the arrow handler will not be shown. You only can set notifications from view mode, not in build/edit mode. When you have added notification from a dashboard, click “bell” (show notification) icon next to … (ellipsis) icon; this will show all notifications have been added to that dashboard. Or, you can check all notifications added from Analytics Studio or from the Analytics tab and look for the Notifications menu on the left panel.

H  ands-On Notifications 1. Open Analytics Studio, and open Global Accounts dashboard built in the previous chapter. 2. Edit Global Accounts dashboard; click a number or chart widget, and under Widget properties at the left panel, make sure “Show widget actions” is enabled. 122

Chapter 7

Exploring the Dashboard

3. Save the dashboard, and exit from edit mode. 4. Hover your mouse over the widget edited in step 2, click arrow icon, then click “Set Notification.” 5. Depending on the operator used for that widget, for example, count, sum, average, and so on, it will be used as the criteria, then select the operator, and value threshold (see Figure 7-2). 6. Next, you should be notified only once if the threshold value meets, or every time when the schedule runs. 7. Schedule when the notification should run, from weekday, daily, weekly, and time. 8. Click Save and Run button. 9. Once added, notice a number in a blue square appears when you have Notifications panel open.

Figure 7-2.  Set notification to a number widget

123

Chapter 7

Exploring the Dashboard

10. The notification details from status, last modified, and criteria will be shown in that panel. 11. Now click the Analytics Studio tab, notice Notifications tab, click the tab, and you will see all notifications that you have set up from all dashboards and status if the criteria have been met (see Figure 7-3).

Figure 7-3.  Monitor all notifications

Note  For widget built on step contain binding for dynamic chart, the user will be not able to set notification on that widget. For notification on value table, you can select any measure column added to the table.

124

Chapter 7

Exploring the Dashboard

Figure 7-4.  Notifications will appear in Lightning as well as e-mail and Salesforce mobile app

Annotations With annotation feature, you can annotate dashboard widgets with comments posted in the dashboard and in chatter. You can hold conversations about the widget, including posting a screenshot of the whole dashboard. Similar to chatter, you can mention someone to get his or her attention on the post, and that person can comment on the annotation. Once the issue is resolved, you can select Resolve from annotation post, the annotation will be moved under the Resolved tab. Also, reopen back the annotations when needed. You can add many annotations for a widget in the dashboard. Same as notification, annotations are only available for chart, table, and number widget, and you should enable “Show widget actions”; otherwise the menu will not appear when you hover mouse over the widget.

Enabling Annotations Annotations are not enabled by default, you need to reach out to your Salesforce admin to enable this from setup, search for Feed Tracking in Quick Find box, look for Analytics Asset, and select Enable Feed Tracking. Once enabled, open a dashboard, notice Annotations icon appears next to the … (ellipsis) icon. All annotations added to the dashboard will appear here, including open and resolve annotations. 125

Chapter 7

Exploring the Dashboard

H  ands-On Annotations 1. Open Analytics Studio and then Global Accounts dashboard built in the previous chapter. 2. Edit Global Accounts dashboard; click a number or chart widget, and under Widget properties at the left panel, make sure “Show widget actions” is enabled. 3. Save the dashboard, and exit from dashboard designer. 4. Hover your mouse over the widget edited in step 2, click arrow icon, then select “Annotate” (see Figure 7-5). 5. To share an update and notify users; you can mention the user name by typing @ user name. 6. Select “Attach current screenshot.” 7. Click the Share button. 8. Verify the annotation created under Open tab in All Annotations panel and also in chatter feed.

Figure 7-5.  Adding annotation to the widget

126

Chapter 7

Exploring the Dashboard

9. Click the arrow, and select Resolve to move the annotation from Open to Resolved tab. Similar to chatter in a record, when you follow a dashboard, you will get a notification if someone annotates the dashboard.

S  hare Widget When a user explores a dashboard, after Set Notification and Annotate actions, “Share” is the third action available from widgets. Same with previous actions, this action is only available for chart, table and number widget. Hover mouse over the widget, and click arrow drop-down; arrow drop-down is only available if the widget is enabled for “Show widget actions” (Figure 7-6).

Figure 7-6.  Access Share action from the drop-down menu There are two main tabs under Share action: Post to Feed and Download (see Figure 7-7).

P  ost to Feed This offers the user ability to capture the widget as an image and post it to chatter feed: •

User can share the widget as chatter post to user feed or to a chatter group.



Add comment for the post (this is optional).



The widget will be shared as an image. 127

Chapter 7

Exploring the Dashboard

Download With download, users can download the widget as •

Image (PNG format)



Excel format



CSV format, this is useful when need to download raw data from a dataset from a table widget.

Figure 7-7.  Share widget as feed or download

Show Details Show Details action will show detail info of a widget, from dataset used, filters applied, dimensions and measures field, and last run metrics (ms). In the Dashboard Inspector, it shows all steps available in the dashboard, and when we click a step, the details of the step will be shown.

128

Chapter 7

Exploring the Dashboard

While Show Details action shows the same information as if we click step from Dashboard Inspector, however, we do not easily know a step is related to which widgets. So, by clicking “Show Details” from a widget, this will guide us exactly what is the step name that powers the widget, including all information related to the widget. This action is most useful for dashboard explorer to analyze data shown in the widget, including dashboard builder to make sure the widget is showing the correct data, for example, not using wrong dataset, wrong filters, and and so on (see Figure 7-8). I’ll not repeat content shared in Dashboard Inspector, but check out screenshot as Figure 7-7 for information available from Show Details.

Figure 7-8.  Information from Show Details of a widget

E xplore Same as previous actions, explore action is only available for chart, table, and number widget. But in addition to enabling “Show widget action,” “Show explore action” also must be enabled too. In some cases, you may need to disable explore action, so users will be not able to explore and see raw data. 129

Chapter 7

Exploring the Dashboard

When exploring a widget, Einstein Analytics will create a new lens, and the user can do analysis from here, including to change chart type, table mode, filter, until editing with SAQL. If users need to store the lens modified, they can store it in their private app or public app if the user has editor or manager permission for the app. As mentioned in earlier chapter, this is a difference with standard Salesforce reporting; the lens created will not impact the dashboard or widget in the dashboard.

Hands-On Explore Widget 1. Open Analytics Studio, and open Global Accounts dashboard built in the previous chapter. 2. Edit Global Accounts dashboard; click a number or chart widget, and under Widget properties at the left panel, make sure “Show widget actions” is enabled, and “Show explore action” is also enabled. 3. Save the dashboard and exit from edit mode. 4. Hover your mouse over the widget edited in step 2, click arrow icon, then click “Explore” action (see Figure 7-9).

Figure 7-9.  Exploring a widget

130

Chapter 7

Exploring the Dashboard

5. This will open the widget as a new lens. By default, it would be the same chart type or table with the widget; except for number widget, it would be a bar chart without grouping. Filter added to the dashboard, and widget will be applied. 6. If it is a bar chart, you can change the grouping by changing the fields under bar, or you can add another level of grouping too. 7. Optionally, you can save the lens to your private app or to a public app to be shared with your team. 8. You can perform all features offered by lens, such as Clip to Designer, present, save, share, and clone. We have discussed this in Chapter 5. In case if you need to export data to Excel or CSV file, you can use the same method as shared in Chapter 5; open the widget as lens, change the format to the table (if necessary), click Share, Download, then select to download as Excel or CSV format.

Widget Built with SAQL For widgets built with SAQL, users will be not able to update the lens with clicks; but users must use SAQL too to edit. To check if a widget is powered by step built using SAQL •

For dashboard builder, edit the dashboard, and click pencil icon “Edit Step and Widget” at the bottom; you will find that you cannot edit the values such as bar length, filter, query limit, and so on.



For dashboard user, click “Show Details” action, then “View more details” button, select “Original Query”; SAQL powered step will show SAQL here, while a non-SAQL step will show JSON format compact form.



When you use a binding in compact form (non-SAQL) in the dashboard widget, you will not be able to edit the widget. However, you can go to the JSON mode and edit the step/widget as your needs.

131

Chapter 7

Exploring the Dashboard

E mbedding Einstein Analytics Dashboard to Salesforce Page As discussed in the previous chapter, to explore Einstein Analytics dashboard from Salesforce, users just need to click the Analytics tab and find the dashboard to explore. However, for some scenarios, it would be greater if the user is able to access right in Lightning record page, app page, and Home page. Same as viewing dashboard from Analytics tab or Analytics Studio, the user still needs the same licensing to view dashboard from the Lightning page. When you embed a dashboard, the whole dashboard will be shown; you cannot just show a widget. To enable sharing option, in Lightning, the component needs to be with minimum frame size 800 x 612 pixel. If the widget has explore action enabled, users will be able to explore the widget from Lightning too. Explore will open Analytics Studio and create a new lens. Faceting and filtering will work as per normal. To add Einstein Analytics dashboard to a Lighting page, the Salesforce system admin just needs to drag Einstein Analytics dashboard component to the Lightning page. Once added, there are a few options that can be configured:

132



Dashboard name: List of Einstein Analytics dashboard will be shown here, make sure the dashboards selected are in the app accessible by our users.



Height: Component height in pixel.



Filter: This is optional, most useful when we need to auto filter the dashboard based on record Id.



Show Sharing icon: Only can be enabled when the component frame size is more than 800 x 612 pixels.



Show tile: To show/hide dashboard title.



Show Header: To show/hide header, which includes title, dataset last refresh, and Analytics Studio icon.



Open Links in New Windows: If there is a link in the dashboard, clicking this will open the target as a new window.

Chapter 7

Exploring the Dashboard



Hide on Error: To show/hide if an error occurred in the dashboard.



Set Component visibility: This is standard lightning component features if we want to show the component just for a group of users, such as profile or record values.

Hands-On Adding Dashboard to Home Page Scenario: To add an interactive dashboard using Einstein Analytics to show all open and closed Opportunities for current quarter and next quarter in the Lightning Home page. The assumption is that you already have a dataset created from a dataflow (see Figure 7-10). Make sure the following fields are added to the dataflow: Account Id, Account Name, Account Type, Account Number, Opportunity Id, Opportunity Name, Opportunity Stage, Opportunity Amount, Opportunity Close Date, Opportunity Owner Name, Is Closed, and Is Won.

Figure 7-10.  A dataflow pulls data from Account, Opportunity, and User objects 1. Open Analytics Studio. 2. Create a new dashboard. 3. I’ll not go through step by step on creating a dashboard, as we already covered in Chapter 6. Here is the dashboard created; you can create your own Opportunity dashboard, but make sure the fields mentioned earlier are included in the dataset. I’ll name my dashboard as “Current & Next Quarter Opportunity” (see Figure 7-11).

133

Chapter 7

Exploring the Dashboard

Figure 7-11.  A dashboard built with a dataset extract from Account, Opportunity, and User objects 4. Let’s embed the dashboard into Lightning Home page, navigate to Lightning Home page, and click “Edit Page” under the gear icon at the top right screen. 5. Drag “Einstein Analytics Dashboard” component above the Quarterly Performance component.

134

Chapter 7

Exploring the Dashboard

6. Select the component, and enter the following in the properties: •

Dashboard: Current & Next Quarter Opportunity



Height: 500



Show title: Check

7. Click Save button then Back button. 8. You should be able to filter and facet the dashboard as you are opening the dashboard from the Analytics tab, but note that Shared action will not available here (see Figure 7-12).

Figure 7-12.  Einstein Analytics dashboard embedded as Lightning Home page

Hands-On Adding Dashboard to Record Page Scenario: To add an interactive dashboard using Einstein Analytics into Account record to show all Opportunities related to that Account. Building Dashboard Let us clone “Current & Next Quarter Opportunity” dashboard as “Opportunities of Account”; we can use back the same dataset, and nothing needs to change in the dataflow. 135

Chapter 7

Exploring the Dashboard

1. Open Analytics Studio. 2. Clone “Current & Next Quarter Opportunity” dashboard as “Opportunities of Account.” 3. Modify the dashboard accordingly; for this dashboard I’ll remove all filters as it supposed to be filtered to a related Account (see Figure 7-13).

Figure 7-13.  Modified dashboard without filters 4. Open an Account record where you want to embed the dashboard, then click “Edit Page” under the gear icon at the top right screen. 5. Drag “Einstein Analytics Dashboard” component above Activity/ Chatter tab component.

136

Chapter 7

Exploring the Dashboard

6. Select the component, and enter the following in the properties: •

Dashboard: “Opportunities of Account”



Height: 400



Untick all check boxes

7. Make sure “Filter Builder” is selected, then click the “+ Add Dashboard Filter” button: •

Select the dataset



Dataset field: Account ID



Operator: Equals



Object field: Account > Id

8. Click the OK button, click the Save button, then Back button; the result shows as in Figure 7-14.

Figure 7-14.  Account lightning page embedded with Einstein Analytics dashboard

137

Chapter 7

Exploring the Dashboard

In the same way, you can embed the Einstein Analytics dashboard to any other Lightning record pages without the need to write any script. In the last option, you also can embed Einstein Analytics dashboard to Lightning App page, where the app page can be worked in both web browser and mobile app.

S  ummary In this chapter, we discussed everything in exploring a dashboard. We start with using Dashboard Inspector; this tool can not only be used by dashboard explorer but also dashboard builder to debug the dashboard widgets, to analyze steps, and to optimize dashboard performance. Next, we learn how to set notifications action on widgets; this notification is personal and will not impact other users; we’ll get notifications once all the criteria defined are met. Annotation is the next action; we can use it to collaborate with our team in discussing a business metrics show in a widget. Annotation directly integrates with chatter; users can set the annotation as resolved so it will not appear as Open tab. We discuss the next action which is sharing widget as chatter feed or by downloading the widget as an image or Excel file or CSV file. Explore action, as it is named, is very useful for users to explore dataset as a lens; all existing filters from the dashboard will be automatically added. Embedded Einstein Analytics dashboard to Salesforce Lightning page is another further step to bring the dashboard easily access by users from Lightning Home, record, and app page. Next, in Chapter 8, we will learn how to set security to the dashboard and the data, so stay tuned!

138

CHAPTER 8

Applying Security in Einstein Analytics In this chapter we will discuss all aspects of security that can be implemented in Einstein Analytics. Same as other reporting tools, you always need to secure the access from multiple points of views, for example, to hide a particular dashboard completely from all users and only make it visible to certain users, make the dashboard visible to users, but not allow them to edit it, and so on; this is controlled in the app. For a more advanced technique, you can show the dashboard result based on who is the user, so we can configure that everyone will not see the same results in a dashboard; this is controlled in the Dataset. But before we look at apps and dataset security, we also can control the base permissions for the user – things that a user can do in Einstein Analytics in general, so this is a blanket permissions given for that particular user. Things like users are not allowed to download data from Einstein Analytics, or to upload external data to Einstein Analytics, and so on; this permission is controlled under the permission set. In this chapter, we will learn the following topics: •

Permission set assignment



Apps level sharing



Security predicate



Sharing inheritance

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_8

139

Chapter 8

Applying Security in Einstein Analytics

Permission Set Assignment This setting is configured in Salesforce user detail, not in Einstein Analytics. If you know how Salesforce users are assigned with extra permission using permission sets, this is exactly the same. Depending on the Einstein Analytics licenses purchased, you will get an additional two permissions set added into your Salesforce org.: Einstein Analytics Platform Admin and Einstein Analytics Platform User for standard Einstein Analytics license or Einstein Analytics Plus Admin and Einstein Analytics Plus User for Einstein Analytics Plus. As these are prebuilt permission sets, you cannot edit the permissions, but Salesforce admin will be able to clone the permission set and adjust the system permissions.

Figure 8-1.  Sample of the permission set for Einstein Analytics We will not discuss each of the permissions as in Figure 8-1, but if you look at the permission name and description, some of them are pretty obvious; for “Create and Edit Analytics Dashboards” permission, without this permission, the user will be able to explore dashboards, but not create or edit any dashboards; for “Upload External Data to Analytics,” this permission gives ability for the users to load CSV file as a dataset in Einstein Analytics. 140

Chapter 8

Applying Security in Einstein Analytics

As per Salesforce permission set model, Salesforce admin can clone the permission set to many permission sets, each permission set can have different permissions enabled, and a user can be assigned with multiple permission sets.

Apps Level Sharing We discussed apps in Chapter 5 when we started creating lens; we can share the App by •

User name



Public group



Role

With access as •

Manager



Editor



Viewer

The manager is the highest level of access, where users with Manager access will be able to view, edit, share, and delete the app. Users assigned with Editor access will be able to view and store dataset as a lens into the app. The Viewer users only able to view dashboard, lens, and dataset, so the user will only able to save lens or dashboard into other app where the user has editor or manager access or to store it in his/her own private apps. However, users with Manage Analytics permissions will be able to view and edit all dashboards and lens stored in all public apps, including access to the Data Manager. While users with Einstein Analytics license and Modify All Data or View All Data permission in Salesforce will be able to see all Apps, Manage Analytics should only be given to Einstein Analytics admin users.

S  ecurity Predicate Security predicate is a filter condition that defines row-level access for users to a dataset, so dashboards using that dataset will be applied the same row-level access. Every time users accessing dataset (including from dashboard or lens), the system will check the 141

Chapter 8

Applying Security in Einstein Analytics

running users detail to compare with the security predicate defined for the dataset. You can use any field in Salesforce user object such as Profile Name, Role Id, User Id, Department, or build your own custom fields. Security predicate is not configured in Salesforce; it will work even for dataset not imported directly from Salesforce. Security predicate just check the running users detail from Salesforce with the dataset. In some cases, we may need to add additional columns in dataset, for example, as an exception to let a profile have visibility to all data in the dataset, no matter what is the profile – in this case, the profile Id need to be added in the security predicate.

Syntax The syntax is fixed; you cannot put the dataset column after operator; it will not work. Example valid security predicate: 'ProfileId' == "$User.ProfileId" •

‘ProfileId’ is API field name in dataset.



== is operator.



“$User.ProfileId” is running user profile Id in Salesforce.

You can use || as OR; && as AND; and use () to set order of operators in the security predicate.

Tips The API field name should be within single quotes (‘ ’), while the right side of the operator should always be in double quotes (“ ”). Let us have another sample of security predicate; in this sample, we are going to give visibility of all rows to all users with Marketing profile, while other users only allowed seeing data in their region. 'Region' == "$User.Region__c" || 'View_All' == "$User.ProfileId"

142

Chapter 8

Applying Security in Einstein Analytics



Region and View_All are API field names in the dataset.



We use a custom field called Region__c in the User object in Salesforce.



View_All should contain profile Id of Marketing profile for each row in the dataset.

Notes  Security predicate does not support using IN or comma, so if you have multiple profiles that need to see all rows, you need to have multiple fields for each profile, for example: 'Region' == "$User.Region__c" || 'View_All_1' == "$User. ProfileId" || 'View_All_2' == "$User.ProfileId"

Hands-On Security Predicate 1. Open Analytics Studio. 2. Create the following dataset from CSV files; you need to change values in View_All to a valid profile Id in your Salesforce org. (see Table 8-1).

Table 8-1.  Load the Following Table As a New Dataset and Name It “Top Account” Department Account Name

View_All

Sales

Data Inc

00eB0000000KmquIAC

Sales

Manager Inc

00eB0000000KmquIAC

Support

Workflow Inc

00eB0000000KmquIAC

Sales

Process Inc

00eB0000000KmquIAC

Support

System Inc

00eB0000000KmquIAC

Support

Business Inc

00eB0000000KmquIAC

**You must use Id with 18 characters, not 15 characters 143

Chapter 8

Applying Security in Einstein Analytics

3. Find the dataset created, click the dataset to verify that the data loaded is correct, and you should see six records. 4. Go back to the Dataset tab, and click Edit from the arrow at far right. 5. Click pencil icon under Security Predicate, enter the following ‘Department’ == “$User.Department” || ‘View_All’ == “$User. ProfileId” 6. When you click out of security predicate box, the system will auto check and reject if the security predicate syntax is invalid, such as “$User.Department” == ‘Department’ (wrong order), and also if the value does not exist, such as ‘Department’ == “$User. UserDepartment” (UserDepartment field does not exist in User object). However, the system will not validate and/or reject if the column name in dataset does not exist, such as ‘UserDepartment’ == “$User.Department” (UserDepartment field does not exist in the dataset). 7. If the syntax check is passed, the security predicate will be saved automatically. 8. Change your Salesforce user detail Department to “Sales.” 9. Go back to Analytics Studio, and open Top Account dataset again; for my sample, I should only see three records as in Figure 8-2.

Figure 8-2.  Security predicate filter row Department = Sales 144

Chapter 8

Applying Security in Einstein Analytics

10. Move the dataset to shared app from edit the dataset. 11. Now log in as a user with Marketing profile, open the dataset, and it should show six records (see Figure 8-3), because we made Marketing profile Id as the exception.

Figure 8-3.  Security predicate filter with exception

Role Hierarchy Access As you see from previous hands-on, security predicate supports filter on a specific Id or word; however, if we combine with “flatten” transformation to flat all Role Id in the dataflow, we can use security predicate to let users in the higher role hierarchy to access data visible for users below the role hierarchy. Check out Figure 8-4 for a sample of the dataflow with flattening nodes.

Figure 8-4.  Dataflow with flatten nodes 145

Chapter 8

Applying Security in Einstein Analytics

Check out Figure 8-5 to set parameters in the flatten nodes.

Figure 8-5.  Flatten nodes properties You will see fields added from flatten nodes in dataflow, but not in the dataset; see Figure 8-6 for fields in dataflow.

146

Chapter 8

Applying Security in Einstein Analytics

Figure 8-6.  sfdcRegister in dataflow with fields from flatten nodes Here is the security predicate for role hierarchy access 'OwnerId' == "$User.Id" || 'Owner.Role.Roles' == "$User.UserRoleId"

Notes This is only to give access to specific dataset based on Salesforce role hierarchy; it is not related on the security setting for the object in Salesforce, and it also does not relate if there is sharing rules added for that object in Salesforce.

Sharing Inheritance As you can see in the security predicate, we defined row-level security based on criteria we defined in Einstein Analytics; it has no relationship with Salesforce record security. Sharing inheritance will give us the ability to use the same row-level security defined in Salesforce; this includes object sharing, role hierarchy, manual sharing, team sharing, and sharing rules added for the object. 147

Chapter 8

Applying Security in Einstein Analytics

This sounds perfect for Salesforce customers to limit data visibility as defined in Salesforce; however, sharing inheritance has limitations; if a user can see more than 3,000 rows of data and the user does not have “View All Data” permission, sharing inheritance will not work. Sharing inheritance is defined in the dataflow on the register node when creating dataset. Sharing inheritance is not enabled by default and is not automatically applied to the dataset.

Enable Sharing Inheritance From Salesforce setup menu, in the Quick Find box, type Analytics, and then click Settings. Look for Inherit sharing from Salesforce and select it.

C  onfigure Dataflow Let us create a new simple dataflow with two nodes as in Figure 8-7: 1. sfdcDigest: This is to get data from an object. 2. sfdcRegister: This is to store the data into a dataset.

Figure 8-7.  A simple dataflow to get data from Salesforce and store to a dataset To enable security inheritance, there is no difference in the dataflow sfdcDigest node; we define the object will be used as a sharing source in the sfdcRegister node. For this sample, since we only have one sfdcDigest from a Salesforce object, the sharing source is to use this object in sfdcDigest; see Figure 8-8, the sharing source is Master_ Data__c object.

148

Chapter 8

Applying Security in Einstein Analytics

Figure 8-8.  Configuring sfdcRegister node with sharing source

R  esult To prove this work, let’s do a quick hands-on. For this exercise, you can use any objects with less than 3,000 records, and the object sharing setting must be set to private. Build the dataflow, and configure the sharing source as in Figure 8-7. Figure 8-9 is a screenshot taken from a user with View All Data permission.

Figure 8-9.  A dashboard with count of rows of a dataset

149

Chapter 8

Applying Security in Einstein Analytics

Figure 8-10 is a screenshot taken from the same dashboard but open by a standard user.

Figure 8-10.  The same dashboard open by a standard user

S  ummary In this chapter, we discussed every aspect of security that can be implemented in Einstein Analytics. We start with blanket basic permissions on what a user can do in Einstein Analytics. This is defined in the permission set and can be applied per-user basis. Next, we discussed apps security. We can share apps to users based on user name, role (including subordinates or not), and public group. As you can see, these all sharings are related to Salesforce setup. Then, similar to Salesforce report or dashboard folder, the apps manager can define the level of access for each user or role or group, from manager, editor, and viewer. With security predicate, we can define row-level security; the system will compare user detail with data in the dataset. You can set exceptions for particular users based on role or profile or custom fields. We also can use the flatten transformation node in dataflow to give row-level access based on Salesforce role hierarchy. The last option of security aspect that can be implemented in Einstein Analytics is sharing inheritance; this is pretty nice when you can inherit all security measure as per defined in Salesforce; however, a user is limited to have accessibility maximum to 3,000 rows only; otherwise it will not be used. In the next chapter, which is the last chapter for this book, we will discuss advanced topics related to Einstein Analytics. We will learn a few transformation nodes in dataflow and real-time Salesforce data access with SOQL, SAQL, JSON, static step, and binding.

150

CHAPTER 9

Advanced Topics Congratulations that you are now reaching the last chapter of this book. By now, you know what a dataset is, how to import data into Einstein Analytics, how to build a dashboard from scratch, explore dataset with lens, create simple dataflow, enable data sync with Salesforce, and explore dashboard with all actions offered by Einstein Analytics; you also learned how to implement security. In this chapter, we will learn a few techniques usually faced when building a dashboard in Einstein Analytics; we will learn the following topics: •

computeExpression node, computeRelative node, slideDataset node, and filter node



Augment node with multiple value lookup



Real-time data pull from Salesforce with SOQL



JSON



SAQL



Binding

D  ataflow Nodes In Chapter 3, we have built dataflow hands-on, and the following node types have been discussed: •

sfdcDigest



Filter



Augment



computeExpression



sfdcRegister

© Johan Yu 2019 J. Yu, Getting Started with Salesforce Einstein Analytics, https://doi.org/10.1007/978-1-4842-5200-0_9

151

Chapter 9

Advanced Topics

We will not discuss sfdcDigest, augment, and sfdcRegister anymore as they are pretty straightforward. But let us look at the following nodes:

c omputeExpression Node The purpose of this node in dataflow is to create “formula fields” as in Salesforce; therefore if you need to have formula fields that do not exist in Salesforce, you can build the formula field for Einstein Analytics dashboard with computeExpression node in Dataflow. Let’s have a sample; in Figure 9-1, we have a lens where Account Type may contain: Customer – Channel, Customer – Direct, and Prospect. The requirement is to combine any type that contains Customer as Customer.

Figure 9-1.  Original widget group by Account Type 1. Add computeExpression node Enter the Node Name and Source, then click + Add Field button (see Figure 9-2).

152

Chapter 9

Advanced Topics

Figure 9-2.  New computeExpression node 2. Enter the field name, label, type, and SAQL expression. We will learn SAQL later in this chapter. Click the Save button to continue (Figure 9-3).

153

Chapter 9

Advanced Topics

Figure 9-3.  Adding field Each type has different parameters: •

Text: Precision and Default Value



Numeric: Precision, Scale, and Default Value



Date: Date Format, Is Year-End Fiscal Year, Fiscal Month Offset, Select the first day of the week, Default Value

If the SAQL expression returns a null value, it will be replaced with a specified value defined in the default value. Precision defines the length of the text value or the maximum number of digits for numeric values while scale for numeric to define the number of digits of the decimal point, and it must be less than precision value; the sum of Precision + Scale should be