cancel
Showing results for 
Search instead for 
Did you mean: 
katherineyu
Sisense Team Member
Sisense Team Member

Start Your Sisense Notebook  

About Notebooks

Notebooks is available for all Sisense Linux Deployments starting with version L2021.12. V2 of Notebooks is available with L2022.5, but improvements are continually added with the latest upgrades. We recommend the latest version of Sisense for the best experience. 

Notebooks is a Cloud Service, which means that the feature stores the result sets of the Notebook queries into the Sisense Cloud for 30 days– or until the query is rerun. 

Notebooks allow Analysts to connect directly to their databases and run ad-hoc queries using SQL, Python, and R. This feature invites advanced analysts that are already familiar with these languages to effectively extract their data as quickly as they can type without having to learn a new interface. 

 

Enabling Notebooks

Notebooks is disabled by default; however, it can be enabled by an Admin user from the Admin tab. Once at the Admin tab, navigate to the “Feature Management” page found on the left-hand navigation panel. Scroll down to “Personalized Cloud Services” and there you will find the Notebooks feature toggle. Toggle the feature and click Save. The new Notebooks tab will appear and the service will be up and ready in a few minutes. 

If you see that the Notebooks feature is unavailable and grayed out on your Feature Management page, reach out to your Sisense Customer Success Manager to help enable the feature or upgrade you to L2022.10 to make this feature available for you automatically. 

For On-Prem deployments, the Notebooks feature requires internet access to interact with the Sisense Cloud. 

 

Getting Started

When navigating the Notebooks tab, the page will vary depending on your user type. 

  • Admins will have the ability to see all Notebooks created by all users. They will have the ability to create their own Notebooks, and they will be able to query the databases connected to every Notebook. 
  • Data Admins will have all of the same access as the Admins described above. 
  • Data Designers will be the main user type for Notebooks with the most flexibility for access control. They will have the ability to create their own Notebooks, share Notebooks that they own with View or Edit mode and be the recipient of Notebooks with either View or Edit mode. 
  • Designers are “View-Only” users in Notebooks. They are able to be recipients of shared Notebooks, but can only view the Charts and Text boxes of the Notebooks and they cannot see the underlying SQL or Code that is in the Notebooks. 
  • Viewers are also “View-Only” users in Notebooks and have the same access as the Designers described above. 

When creating a new Notebook, the user will be prompted to name their Notebook and then be redirected to a data source connection modal. You can choose your preferred connector and enter your credential, or click “Cancel” if you’d like to skip connecting to a data source and write Python and R immediately. More information on connecting a data source can be found here.

 

SQL 

You’ll notice that the Notebook starts with an empty SQL cell. If you have not connected a database but would like to still try out Notebooks skip ahead to the “Python and R” section. The default runtime limit for SQL is 4-minutes. More information on SQL Notebooks can be found here

Example: If you’ve connected a database, go ahead and write your own SQL or copy the example below into the SQL cell. 

 

 

 

select 'Erin' as “Name”, 23 as “Spend”

union all 

select 'Andrew', 22

union all 

select 'Jen', 19

 

 

 

Click Run SQL and view your Preview Table. 

 

katherineyu_0-1666283161333.png

 

Click Chart and Select Data to create a Chart. 

 

katherineyu_1-1666283161440.png

 

Now you have created a chart using SQL in Notebooks!

 

katherineyu_2-1666283161405.png

 

Python and R 

 

While SQLs run directly against the database that is connected to the Notebook, Python and R use the Sisense Deployment resources for CPU and memory. Python and R run on the Compute Service in the Sisense Deployment and each Notebook has its own kernel. The current memory limit is 512 Mib for Code and a 2-minute runtime limit per Notebook. More information on Python and R in Notebooks can be found here

 

Python and R Helper Functions 

SisenseHelper functions are Sisense-specific functions that allow the cells to interact with each other. These functions must be used in order to load data from another SQL cell into the Code Cell for additional transformations, to save the final data frame for creating a Chart,  as well as to create Image Charts with plotting libraries. 

 

Function

Description

SisenseHelper.load_dataframe(‘SQL_Cell_Name’)

Load the output table of a SQL cell named in the function. Define a variable using this function. 

SisenseHelper.save_dataframe(df)

Save the dataframe into the Sisense Cloud so that the preview can be displayed and charts can be created using this output. 

SisenseHelper.save_image(plt) 

Save the image plot into the Sisense Cloud so that the preview can be displayed and chart cells can be created using this image. 

 

Example:

To get started go ahead and click +Code at the bottom of any cell after hovering over it. 

Make sure that the language dropdown has Python 3.9 selected and that the Kernel is running. The header should look something like this: 

katherineyu_3-1666283161332.png

If you skipped the SQL example above, copy this code into your code cell to create a simple table: 

 

 

 

 

 

import pandas as pd

# initialize list of lists

data = [['Erin', 23], ['Andrew', 22], ['Jen', 19]]

# Create the pandas DataFrame

df = pd.DataFrame(data, columns=['Name', 'Spend'])

#Use SisenseHelper.save_dataframe(df) to save the final dataframe.

SisenseHelper.save_dataframe(df)

 

 

 

OR

If you completed the SQL example above, use the load_dataframe() function to load that output as a variable, df, into your code cell: 

 

 

 

import pandas as pd  

# initialize list of lists

df = SisenseHelper.load_dataframe(‘Query_1’) 

#Use SisenseHelper.save_dataframe(df) to save the final dataframe.

SisenseHelper.save_dataframe(df)

 

 

 

Click Run Python and view your Preview Table. 

katherineyu_4-1666283161354.png

 

Click Chart and Select Data to create a Chart. 

 

katherineyu_5-1666283161336.png

 

Now you have a Chart created with Python from Notebooks! 

 

katherineyu_6-1666283161382.png

 

Create an Image Chart with Python

Using Notebooks, Analysts can utilize the plotting libraries available with Python and R to create custom visualizations. These visualizations can then be created as their own Chart cells and can be dragged and dropped within the Notebook along with the Sisense Native Charts created in the examples above. Interactive plotting libraries like plot.ly are not supported at this time. 

Example: 

To create an Image Chart,  click +Code at the bottom of any cell after hovering over it. 

Make sure that the language dropdown has Python 3.9 selected and that the Kernel is running. The header should look something like this: 

katherineyu_7-1666283161335.png

Copy the following Python code which uses the SisenseHelper.save_image() function at the very end into the Code Cell. 

 

 

 

import numpy as np
import pandas as pd 
# Import pyplot for Python charting capabilities
import matplotlib.pyplot as plt
# Generating dummy data for example
data = [{'step': 'Step 1', 'val': 1000},
         {'step': 'Step 2', 'val': 900},
         {'step': 'Step 3', 'val': 500},
         {'step': 'Step 4', 'val': 450},
         {'step': 'Step 5', 'val': 315},
         {'step': 'Step 6', 'val': 300},
         {'step': 'Step 7', 'val': 150},
         {'step': 'Step 8', 'val': 115}]         
df = pd.DataFrame(data)
# Output: matplotlib image representing a funnel chart
def funnel_chart(df, show_n=True,show_pct='NA'):
  #set up data frame
  df['val']=df['val'].astype(int)
  my_max=df['val'][0]
  df = df.sort_values('val',ascending=False).reset_index(drop=True)
  df['pct_of_whole']=np.round((df['val']/my_max)*100).astype(int)
  pct_change=[100]
  for j in range(1,len(df['val'])):
    pct_change.append(int(np.round(df['val'][j]/df['val'][j-1]*100)))
  df['pct_change']=pct_change
  df = df.sort_values('val').reset_index(drop=True)
  df['left']=(my_max-df['val'])/2  df['col']=['indigo','purple','darkviolet','DarkOrchid','MediumOrchid','orchid','plum','thistle']
  #initialize plot
  fig, ax = plt.subplots()
  for i in range(len(df['step'])):
    ax.barh(0.5*i+0.5, df['val'][i], height=0.3, left=df['left'][i], align='center', color=df['col'][i],alpha = 1.0, label=df['step'][i])
    if(show_n==True):
      ax.annotate(' ' + df['step'][i] + ': ' + str(df['val'][i]),xy=(my_max,0.5*i+0.45),horizontalalignment='left')
    else:
      ax.annotate(' ' + df['step'][i],xy=(my_max,0.5*i+0.45),horizontalalignment='left')
    if(show_pct=='of whole'):
      ax.annotate(str(df['pct_of_whole'][i]) + '%' ,xy=(my_max/2,0.5*i+0.45),horizontalalignment='center',color='white')
    elif(show_pct=='of last step'):
      ax.annotate(str(df['pct_change'][i]) + '%' ,xy=(my_max/2,0.5*i+0.45),horizontalalignment='center',color='white')
  # remove border and align chart
  ax.axis('off')
  fig.subplots_adjust(right=0.8)
  return fig  
SisenseHelper.save_image(funnel_chart(df,show_n=True,show_pct='of last step'))

 

 

 

Click Run Python and view the Preview tab to see the custom image chart created with pyplot. 

 

katherineyu_8-1666283161407.png

 

Click Chart to Create a new Cell with the Image from the Preview that can be dragged and dropped as well as seen by Viewers when the Notebook is shared with them 

 

katherineyu_9-1666283161471.png

 

Next Steps


Sisense Notebooks comes with a long list of usability features to make an Analysts workflow as smooth as possible. Refer to our documentation and video tutorials within the documentation to learn more about the additional features in Notebooks including Filtering Charts, Exporting Notebooks SQL to Models, Exporting Notebooks Chart to Dashboards, Drag and Drop Interface, Keyboard Shortcuts, and more.

Contributors
Helpful Links

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: