Saturday, September 26, 2015

OBIEE stacked bar chart grouped by values

Once in a while you need to create a stacked bar graph grouped by some values. Unfortunately, OBIEE doesn't quite support this, because the stacked bars are distributed evenly among the X axis. However, its possible to get it done with some workarounds.
Imagine you would have a fact table structure where in one row you would have two current year measures and two last year measures and you would like to show them by months as in the following picture.
Desirable outcome
OBIEE doesn't support this straight forward, but you can manage to pull it off with some tricks. I used a "UNION ALL" report in OBIEE answers to get it done and added three separate parts each part having the month column, the four measure columns and an additional dummy column to distinguish the three datasets.
The first part includes measures of the current year and SUM(0) in the column formula for the both LY columns.
First part of UNION ALL
 The second part includes SUM(0) for the current year measures and the actual LY measures.
Second part of UNION ALL
The third part includes SUM(0) for all four measures. This set will be the set that will serve as the divisor in the graph.
Third part of UNION ALL
Now hide the dummy column.

Next, arrange all the columns in the graph build dialogue in the following way.

Arranging columns in the graph
And there you have it!
OBIEE grouped stacked bars



Saturday, September 5, 2015

Output the list of dashboards in OBIEE

Here I'm going to show how to output a list of all dashboard pages available to the particular user. Such a thing, for example, could be used to substitute the OBIEE default page with a custom made dashboard page.
This can be done with javascript and using the element in the dashboard page. This script will output a list of only available dashboards and a user will see only those ones, where he has an access.
Take the following piece of code and put it on the OBIEE dashboard page in the text element with the "Contains HTML Markup" checked:

<img id="loading" src="/res/s_FusionFX/common/page_lev_connected.gif" />

<div id="dash_list"></div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

<script type="text/javascript">

$.ajaxSetup({

    beforeSend:function(){

        $("#loading").show();

    },

    complete:function(){

        $("#loading").hide();

    }

});



$.ajax({

url: "saw.dll?getDashboardList"

}).done(function( data ) {

    var start = data.indexOf('[');

    var end = data.lastIndexOf(']');

    var len = end-start+1;

    var json_str = data.substr(start,len);

    var json_obj = jQuery.parseJSON(json_str);

    var str = '<br/><br/><table style="width:100%"><tr>';

    $.each(json_obj, function() {

        if (this.folderName!=='Home Page'){

            str += '<td valign="top"><b><font size=4; color=#CCCC00;>' + '&nbsp;&nbsp;' + this.folderName + '</b></font><br/><br/>';

            $.each(this.portals, function() {
 if (this.portalName=='Management Dashboard'){
                   str += '&nbsp;&nbsp;&nbsp;&nbsp;' + '<img src="res/s_FusionFX/common/page_lev_connected.gif"><font size=3><b><a href="saw.dll?Dashboard&PortalPath=' + this.portalPath + '">' + this.portalName + '</b></font></a><br/>';}
else {
                   str += '&nbsp;&nbsp;&nbsp;&nbsp;' + '<img src="res/s_FusionFX/common/page_lev_connected.gif"><font size=3><a href="saw.dll?Dashboard&PortalPath=' + this.portalPath + '">' + this.portalName + '</font></a><br/>';}

            });

            str += '</td>';

        }

    });
str += '</tr></table>'
$('#dash_list').html(str);

});

</script>

The output of the script on the environment I was using:


You can also make some adjustments to the previous code to adjust it to your requirement. I highlighted 4 likely places that you might want and need to adjust.

<img id="loading" src="/res/s_FusionFX/common/page_lev_connected.gif" />
This would be the picture that shows up while the list is being populated (only a second or two though). Here I used the same Oracle logo from OBIEE top right corner, but you could as well add your own picture on the server and make the code point to your picture.

if (this.folderName!=='Home Page'){
This would exclude a particular dashboard from the outputted list. It's pretty useless and you probably wouldn't want to include the same dashboard you're on here. You would need to modify the name according to your particular dashboard name then.

if (this.portalName=='Management Dashboard'){
You might want to highlight a particular dashboard on the list. For such case you can write a separate branch with a special font, picture or something else.

<img src="res/s_FusionFX/common/page_lev_connected.gif">
You can change the image that shows up before the each dashboard. Here I used the same Oracle logo, but you can also customize it to your needs.

Of course, there are a lot of other smaller or bigger adjustments you can do - font colors, sizes etc.

I already did and you probably could use this script for a custom home page and replace the Oracle default home page. In my case I made and added a custom logo of my company, added some custom links to related internal systems on one side, ETL status reports - on the other side and the script in the middle of the page to populate the list of available dashboards in the middle of the page. I also added custom images to the server to use as the bullets for each dashboard. Then I used the PORTALPATH repository variable to direct the user to this page and also modified header.js javascript file to redirect the "home" link from the top of the OBIEE page to this new customized page.