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

Leveraging Sisense Notebooks with Compose SDK

In today’s developer ecosystem, delivering a tailored creator experience is essential for success, especially when integrating analytics into customer-facing applications. Many existing solutions offer a generic, one-size-fits-all approach, typically centered around drag-and-drop interfaces. While these tools may be convenient, they often limit the depth of customization needed for unique business use cases. Additionally, platforms that offer more advanced capabilities usually require adopting proprietary syntax, which can drive up costs by necessitating specialized expertise. Sisense, however, provides a powerful code-first analytics solution that eliminates these barriers. It allows your data teams to leverage their existing skills—such as SQL, Python, and R—to create highly customized insights that align with your organization's specific needs, without needing proprietary languages or systems.

In this article, we’ll explore how you can use SQL specifically to create custom datasets and charts, and then embed those visualizations into your web applications. This workflow emphasizes the creator experience for data teams, empowering them to build meaningful, business-specific analytics that enhances your product’s value.

Building Custom Datasets with SQL

Let’s dive into a specific use case. Assume you have a commerce table with two key columns: `transaction_amount` and `transaction_status`. You need to analyze revenue, categorizing it by transaction type (e.g., paid, refunded, or canceled). This provides insight into gross revenue versus potential revenue lost to refunds or cancellations. Below is the SQL query used to create a custom dataset for this scenario: (Dataset Git Repo) (Data Model Repo )

 

 

SELECT
TO_CHAR(DATE_TRUNC('month', transaction_date), 'YYYY-MM') AS "Date",
transaction_id,
SUM(CASE
WHEN transaction_status = 'Paid' THEN transaction_amount
ELSE 0
END) AS "Actual Revenue",
SUM(CASE
WHEN transaction_status IN ('Refunded', 'Cancelled') THEN transaction_amount
ELSE 0
END) AS "Potential Revenue"
FROM
commerce
GROUP BY
DATE_TRUNC('month', transaction_date), transaction_id;

 

 

This query creates a monthly summary of actual revenue and potential revenue lost due to refunds or cancellations. After running the query, you can preview the output in Sisense and immediately take action.

Integrating Custom Data into Fusion

Once your custom table is generated, you have several options for incorporating it into your analytics workflow:

Adding Notebooks Charts to Dashboards 

1. Integrate within the Semantic Model: The SQL table can be added to Sisense’s semantic layer, allowing you to build charts and dashboards on top of it using Fusion Dashboards or Compose SDK.

2. Build Charts for Integration: You can also directly build charts based on this table and pass them to your frontend team for integration into customer-facing applications.

Screenshot 2024-09-17 at 4.01.02 PM.png


Streamlining Developer Workflows with Compose SDK

Once your data team has completed their SQL-based analysis and crafted custom datasets and charts, the true value lies in how effortlessly developers can integrate these insights into customer-facing applications. By publishing the dataset to the Fusion semantic model, developers can use Sisense’s command-line tools (like '@sisense/sdk-cli') to dynamically generate TypeScript representations of the dataset right within their IDE. This streamlined process ensures that the work done by analysts is directly accessible to developers, enhancing the builder experience by providing immediate access to the datasets. This integration allows developers to efficiently embed highly customized, meaningful analytics into the front end, ensuring that the insights are not only visually compelling but also tailored to the specific needs of the end users.

Creating Custom Visualizations

Once charts have been built in Sisense Notebooks and published to Fusion, developers can begin integrating them seamlessly into front-end web applications using the Compose SDK. This process allows developers to embed dynamic, SQL-powered visualizations directly into customer-facing apps. By leveraging the Compose SDK, developers can access the published charts, configure them for specific frontend needs, and ensure a consistent, interactive user experience. This workflow streamlines the integration of custom analytics into web apps, providing flexibility and efficiency for development teams of all varieties.

This code snippet demonstrates how to integrate both a custom column chart and an existing dashboard widget into a React application using Sisense’s Compose SDK. The `ColumnChart` component displays actual and potential revenue by year, while the `DashboardWidget` component integrates a pre-existing Sisense dashboard into the application.

DashboardWidget 
Sisense CLI 

 

 

import { ColumnChart, DashboardById, DashboardWidget } from '@sisense/sdk-ui';
import * as DM from "../notebooks-tutorial"
import { measureFactory } from '@sisense/sdk-data';

function ComposeSDK() {
return (
<>
<ColumnChart
dataSet={DM.DataSource}
dataOptions={{
category: [DM.ActualVsPotential.transaction_date.Years],
value: [
measureFactory.sum(DM.ActualVsPotential.actual_revenue, 'Actual Revenue'),
measureFactory.sum(DM.ActualVsPotential.potential_revenue, 'Potential Revenue'),
],
breakBy: [DM.commerce.age_range],
}}
styleOptions={{
height: 500,
}}
/>
<DashboardWidget
dashboardOid="66e8aa5e724a0b00338cbed9"
widgetOid="66e8c716724a0b00338cbefc"
/>
</>
);
}

export default ComposeSDK;

 


Conclusion: 

This code-first approach to analytics meets technical creators where they are, empowering data teams and developers alike. Whether your analysts are leveraging their existing skills in SQL through the powerful Notebooks environment or your developers are dynamically generating insights within their IDE using the Compose SDK, Sisense offers a seamless and collaborative experience. By enabling teams to work with familiar tools and environments, Sisense allows you to deliver powerful, tailored analytics that fit your organization’s unique needs. This fluid, creator-friendly workflow ensures that both data teams and developers can focus on building impactful insights without the friction of proprietary systems, enhancing the overall efficiency and creativity of your analytics solutions.

Rate this article:
Version history
Last update:
‎09-20-2024 12:14 PM
Updated by:
Contributors