For over a 12 months, Databricks AI/BI has been democratizing enterprise intelligence and analytics throughout your group with extremely visible and interactive low-code AI/BI Dashboards. Following a quick point out in our most up-to-date AI/BI roundup weblog, we’re excited to showcase the flexibility to outline expressive, reusable customized calculations in AI/BI Dashboards. Customized calculations let you mannequin your information in additional expressive methods on high of supply datasets to create richer, extra interactive, and extra performant dashboards.
Customized calculations are outlined utilizing acquainted SQL syntax, so there’s no studying curve to make use of them. Crucially, customized calculations additionally let you outline aggregations and transformations on high of your dashboard datasets with out modifying the unique dataset queries. They arrive in two kinds:
- Calculated measures are aggregated calculations that may be utilized dynamically throughout totally different groupings as wanted by totally different visualizations. Instance:
(SUM(value) - SUM(value)) / SUM(value)
- Calculated dimensions are non-aggregated calculations which can be utilized row-wise. These are useful for formatting or reworking particular person row values. Instance:
TRY_DIVIDE(fare_amount, trip_distance)
Why use customized calculations?
Lowered dataset sprawl
Suppose you may have the next dataset:
| Merchandise | Area | Value | Value |
| ------- | ------ | ----- | ---- |
| Apples | USA | 30 | 15 |
| Apples | Canada | 20 | 10 |
| Oranges | USA | 20 | 15 |
| Oranges | Canada | 15 | 10 |
You need to visualize revenue margin by area. With out customized calculations, you would wish to create a brand new dataset with a margin column:
| Area | Margin |
| ------ | ------ |
| USA | 0.40 |
| Canada | 0.43 |
Whereas this method works, the brand new dataset is static and may solely assist a single visualization. Filters utilized to the unique dataset don’t have an effect on widgets utilizing the brand new datasets with out further handbook changes.
With customized calculations, you’ll be able to categorical the revenue margin as an aggregation utilizing the system: `(SUM(Value) - SUM(Value)) / SUM(Value)`
Although this measure is outlined on the unique, ungrouped dataset, it’s dynamic. When it’s utilized in a visualization, it robotically updates to replicate groupings and filters utilized to the dataset. On this instance, we will even use the identical customized calculation to calculate revenue margin per area in a single visualization, and revenue margin per product in one other visualization. With out customized calculations, this is able to require not less than two further “bespoke” datasets outlined with the correct groupings.
To this point, utilization has indicated that dashboard authors want lower than half as many datasets to assist the identical variety of visualizations after they use customized calculations.
Extra unified interactive filtering
Interactivity is a key part of what makes AI/BI Dashboards highly effective. Nonetheless, interactive filtering by means of filter widgets and cross-filtering operates on a per-dataset foundation, which signifies that ease of interactivity takes a success when visualizations are splintered throughout many datasets. In such instances, customers could must take further steps to filter all desired widgets.
Consolidating datasets as detailed above permits the identical filters to take impact throughout extra visualizations. This ends in a extra constant, intuitive expertise – widgets primarily based on the identical underlying information are extra simply configured to react to the identical filters.
After all, customized calculations are additionally supported in static filters outlined per-widget. You’ll be able to learn extra about interactivity in AI/BI Dashboards right here.
Expressive formatting
Customized calculations embody assist for over 40 totally different capabilities and expression syntaxes, overlaying primary arithmetic, aggregations, conditional case expressions, information kind casting, and a slew of capabilities for string/date manipulation.
These capabilities permit for greater than what’s already provided within the visualization editors. For instance, you’ll be able to:
- Assemble arbitrary strings utilizing the
`CONCAT` and `CONCAT_WS` capabilities, e.g. `CONCAT(first_name, ‘ ‘, last_name)`
- Format dates utilizing the `DATE_FORMAT` perform, e.g.
`DATE_FORMAT(date_field, ‘MMM dd YYYY’)`
- Create customized class strings utilizing `CASE` expressions, e.g.
CASE
WHEN age
WHEN age >= 18 AND age
WHEN age >= 25 AND age
WHEN age >= 35 AND age
WHEN age >= 45 AND age
WHEN age >= 55 AND age
WHEN age >= 65 THEN ’65+’
END
Streamlined dataset authoring
The introduction of customized calculations enhances the dataset authoring expertise in some ways:
- Customized transformations will be siloed into well-labeled customized calculations, preserving litter out of dataset textual content.
- A brand new dataset schema view particulars what fields can be found to reference in calculations, and their information varieties.
- On the spot expression validation and information kind inference computed client-side can be found for customized calculations.
- A semantically constant set of datasets in your dashboard is simpler to attain when there may be much less dataset sprawl. Having fewer, extra coherent datasets minimizes confusion and additional “detective work” to relearn how your datasets are structured each time you must replace your datasets.
Efficiency in-built
Widgets utilizing customized calculations are topic to the identical efficiency optimizations as all different widgets in AI/BI dashboards. This consists of caching question outcomes and quick client-side computation for small datasets.
As well as, having fewer datasets that carry out much less complicated grouping operations ends in sooner dataset question execution, dashing up iteration time when authoring and decreasing load time when viewing.
The way to create and use customized calculations
To create and use a customized calculation:
- On the related dataset, click on Customized Calculation.
- Within the panel that opens, fill out the Title and Expression fields, utilizing the dataset Schema View and built-in expression validation to information your expression authoring. Optionally, write a Remark describing what your calculation is doing. Click on Create.
- Now you can view your customized calculation within the dataset schema view and choose it simply as you choose every other subject within the visualization editor.
For full directions, see the customized calculations documentation. If you’re new to AI/BI dashboards, take a look at this tutorial to get began.
Conclusion
Customized calculations convey a brand new degree of expressivity and suppleness to the AI/BI Dashboard authoring expertise and allow extra unified interactive experiences for dashboard customers. Take a look at the documentation for much more particulars on find out how to handle your customized calculations and for a full checklist of supported capabilities and expression syntaxes.
If you’re able to discover the most recent in AI/BI, you’ll be able to select any of the next choices:
- Free Trial: Get hands-on expertise by signing up for a free trial.
- Documentation: Dive deeper into the small print with our documentation.
- Webpage: Go to our webpage to be taught extra.
- Demos: Watch our demo movies, take product excursions and get hands-on tutorials to see these AI/BI in motion.
- Coaching: Get began with free product coaching by means of Databricks Academy
- eBook: Obtain the Enterprise Intelligence meets AI eBook
We won’t wait to see what you construct with customized calculations, and worth your suggestions as we proceed to broaden this function — tell us what assist for much more expressive calculations you’d prefer to see!