‘Analyze Sentiments’ is a Fiori app that helps you perform Sentiment Analysis on the topics that interest you. To learn more about the app, please go check out these links:

Quick integration of Sentiment Analysis powered by Analyze Sentiments into your app

Ready to get your feet wet?!

Here are a few steps to add a chart control into a UI5 control that supports aggregations (like sap.m.List, etc) and to connect the OData service to this chart.

When you run the app, you will be able to see nice little charts added into each item in the aggregation that shows sentiment information.

Follow these steps to quickly integrate Sentiment Analysis capability into your already existing UI5 app:

1) Insert the chart into the appropriate location in your app. In the sample code below, the chart is embedded into a custom list item:

<List id="main_list" headerText="Vendors">
            <HBox justifyContent="SpaceAround">
                  <ObjectHeader title="playstation" />
                  <viz:VizFrame vizType="bar" uiConfig="{applicationSet:'fiori'}" height="250px" width="250px"> </viz:VizFrame>

2) In the controller code on initialization, add the following code to fill data in the chart that we added into the UI in the previous step:

//Get the reference to the Odata service
var oModel = new sap.ui.model.odata.ODataModel("http://localhost:8080/ux.fnd.snta/proxy/http/", true);
//Get the reference of the control where you want the charts embedded
var oList = this.getView().byId("main_list");
//This code gets the Subjectname from the control in which the chart is going to get embedded. You can see that the subjectname is extracted from the Title of the items in the list
for (var i = 0; i < oList.getItems().length; i++) {
    var oChart = oList.getItems()[i].getContent()[0].getItems()[1];
    var sItemName = oList.getItems()[i].getContent()[0].getItems()[0].getTitle();
//Now we set the data for each item in the list as per the subject that we extracted from the listitem.'/SrchTrmSntmntAnlysInSoclMdaChnlQry(P_SAPClient=\'' + self.sSAPClient + '\')/Results', null, ['$filter=SocialPostSearchTermText%20eq%20\'' + sItemName + "\' and " + "SocialPostCreationDate_E" + " ge datetime\'" + '2014-06-14' + '\'' + '&$select=Quarter,Year,SearchTermNetSntmntVal_E,NmbrOfNtrlSoclPostVal_E,NmbrOfNgtvSocialPostVal_E,NmbrOfPstvSocialPostVal_E'], false, function(oData, oResponse) {
            interaction: {
                selectability: {
                    mode: "single"
            valueAxis: {
                label: {
                    formatString: 'u'
            legend: {
                title: {
                    visible: false
            title: {
                visible: false
            plotArea: {
                dataLabel: {
                    visible: true
                colorPalette: ['sapUiChartPaletteSemanticNeutral', 'sapUiChartPaletteSemanticBad', 'sapUiChartPaletteSemanticGood']
        var oChartDataset = new{
            measures: [{
                name: "Neutral",
                value: '{NmbrOfNtrlSoclPostVal_E}'
            }, {
                name: "Negative",
                value: '{NmbrOfNgtvSocialPostVal_E}'
            }, {
                name: "Positive",
                value: '{NmbrOfPstvSocialPostVal_E}'
            data: {
                path: "/results"
        var oDim1 = new{
            name: "Year",
            value: '{Year}'
        var oDim2 = new{
            name: "Quarter",
            value: '{Quarter}'
        var oDataset = oChart.getDataset();
        var oChartModel = new sap.ui.model.json.JSONModel(oData);
            valueAxis: {
                title: {
                    visible: true,
                    text: "Mentions"
            categoryAxis: {
                title: {
                    visible: true,
                    text: "Quarter"
        var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "valueAxis",
            'type': "Measure",
            'values': ["Neutral", "Negative", "Positive"]
        var feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "categoryAxis",
            'type': "Dimension",
            'values': [new sap.viz.ui5.controls.common.feeds.AnalysisObject({
                    'uid': "Year",
                    'type': "Dimension",
                    'name': "Year"
                new sap.viz.ui5.controls.common.feeds.AnalysisObject({
                    'uid': "Quarter",
                    'type': "Dimension",
                    'name': "Quarter"
    }, function() {"Odata failed", sap.m.MessageBox.Icon.ERROR, "Error", [

PS: Depending on how you add the chart into your app, the above chunk of code will have to be adjusted to get the subjectname and pass it to the chart.

In the above sample code, you can find that the chart in each custom list item is bound to data in a loop. If you have added the chart in a similar control with an aggregation, you would have to modify the lines highlighted above to get the list control and to get the chart reference and searchterm.

What else can you do with the Analyze Sentiments Odata services?

Here’s some more information on our existing Odata services for Analyze Sentiments and some ideas how you can use it in your apps.


What information it gives out


List of Channels (code and name)


List of Searchterms (code and name)


List of (number of mentions, number of positive, negative & neutral mentions, ‘netsentiment value’) for a searchterm given out in daily/weekly/monthly/quarterly/yearly period granularity


List of socialposts for a searchterm in a period


Net sentiment trend in percentage for a searchterm over a specified period.

PS: The last three services retrieves data for all subjects when filter is not applied on searchterms.

Calculations used:

Net sentiment  = P – N

P = sum of weights of positive posts. The weight could be +1(good), +2(very good)

N = sum of weights of negative posts. The weight can be -1(bad), -2(very bad)

Net sentiment trend percentage = (Net sentiment in last n days – Net sentiment in previous n days) / Net sentiment in previous n days.

So on the whole, we have the following information:

i) Number of positive, negative, neutral, total mentions about a Subject

ii) Net sentiment about a subject

iii) Net sentiment trend about a subject which is a percentage.

Here are some sample ways in which the external apps can right away start using our Odata assets:


Control that can be used

Collection to be used

Show the numbers (total, positive, negative neutral mentions or netsentiment) related to a subject



Show the socialposts related to a subject

Table, list, etc


Show the net sentiment trend of a subject



Show chart/graph with the numbers over a period



Related links:

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply