How to Display Dynamic Images from Live HANA 2.0 Data
SAP Analytics Cloud has the ability to load dynamic images that are stored in a HANA 2.0 database. In this blog, I’d like to highlight this feature, but first, let’s talk about some best practices in regards to modeling the data in HANA.
Please note: SAP Analytics Cloud version 2018.22 (at minimum) and a Live data connection to HANA 2.0 data are required for the feature described in this blog post.
Create a Calculation View that contains an image dimension in HANA 2.0
In order for SAP Analytics Cloud to surface an image data from HANA, you’ll have to create a cube calculation view that is joined with a dimension calculation view containing the image. This section will give you example steps on how to model this in HANA 2.0.
Step 1: Create a HANA table that contains the image
In SAP HANA you can store an image as BLOB (Binary Large Object) object, specifically, SAP Analytics Cloud requires it to be the ST_MEMORY_LOB format.
You’ll first create a HANA table to store the images.
You can use this example SQL:
–REPLACE <SCHEMA_NAME> WITH YOUR SCHEMA NAME
CREATE COLUMN TABLE “<SCHEMA_NAME>”.”IMAGE_STORE”(
IMAGE_NAME NVARCHAR(20) PRIMARY KEY,
IMAGE_CONTENT BLOB ST_MEMORY_LOB
Note: the image name should match the name/ID that you will be using to join your image with the table containing measure and additional information in your calculation view.
Next, you’ll upload your images to the SAP HANA table. There are several ways of uploading images into a HANA database including Java and Python. You can download an example Java application in the Image Processing in SAP HANA tutorial.
In this example, I am creating a calculation view that contains information and images for my Sales Managers. After the image-upload, the table in HANA Studio looks like this:
Step 2: Create a Calculation view of type Dimension
The table containing your images now needs to be added to a calculation view of type dimension. This must be done before we can join the table to our calculation view with additional measures.
There is not much to it, just add the table to the calculation view:
Step 3: Join the Dimension Calculation view with a table containing measures
As the image table doesn’t contain any measures, it needs to be joined together with a table that does.
It’s important that the join produces one un-aggregated record per image ID in order for SAP Analytics Cloud to display the image. So, it’s not recommended to join the calculation view with something like transactional data where there could be more than one record per image. If you need to display the image along with transactional data you can always use SAP Analytics Cloud linked analysis to combine the information later on.
In this example, we have a table that contains detailed Human Resources information such as location, role, and salary for each sales manager. We’ll use this table for the join.
To do this, we’ll create a cube calculation view with a star join combining the Dimension Calculation View containing the image with the Employee Information table.
This completes the HANA 2.0 modeling and the calculation view can now be brought into SAP Analytics Cloud.
Consume Dynamic Images from HANA 2.0 in SAP Analytics Cloud
Now that the image dimension has been modeled in HANA 2.0, you can bring the calculation view into SAP Analytics cloud like any other Live HANA model and consume the information in a story.
When you’re designing the story, you can simply add an image widget to the page.
In the builder panel, you’ll see that you can choose between Static or Dynamic image. Select Dynamic image.
Next, add the model that contains the image content to the widget and select the image dimension.
Optional: for the case(s) where an image won’t be returned from the database, or where more than one image is returned, you can add a static alternative image.
Remember that SAP Analytics Cloud can only display the image if the result returned from the database is a single un-aggregated row. If more than one row is returned, then SAP Analytics Cloud will display the alternative image instead. Therefore, the modeling of the join is very important.
In our example, the ability to filter down to a single sales manager must be available. It can be in the form of a filter directly on the image widget, a story or page input control (most likely), or filtering could also be triggered via linked analysis.
Below is an example of an image driven by a page input control. The other sales data in the story charts was brought in via different Live HANA views and combined via linked analysis.
I hope you will like this new feature.
Author: Christina Obry
Christina is the Chief Product Expert for SAP Analytics Cloud’s Business Intelligence portfolio. She has 9+ years of experience in Product Management for various SAP Business Intelligence products. Christina is very passionate about partnering with customers and using real use-cases to drive product improvements. When not at work, you can find Christina enjoying the ocean on an outrigger canoe.