Problem Statement:
A master detail report scenario where the format of detail report does not match that of master and the master report is a drill report.
Solution:
Building a hyperlink in the hierarchal report is little bit complex when compared to a regular hyperlink report since at any point we would not know at which level of hierarchy you are, when you click on the hyperlink.
We would use the ‘Island Resort Marketing’ for our example purposes. ‘Customer Hierarchy’ would be a good pick for the exercise.
Since the master report is a drill report, a user can run the detail report at any level of hierarchy; the detail report then needs to be run at the correct level with the proper input parameters.
Let’s create the sample master and detail report. Here the master report is revenue by country with a drill on the customer hierarchy. The detail report is revenue by service line that is called when the Link is clicked on the master report.
The trick here is that the ‘detail report’ should run fine and in perspective to whichever hierarchy level the ‘link’ is clicked. The detail report is built with each hierarchy level as an optional prompt, in addition to any other required prompt such as time etc.
We would exploit the following properties of drill functionality for making this work:
· There can be only one value of a hierarchy level ‘selected’ at any given point in time
· The one selected value can either be a discrete dimension value or ‘All’
· A combination of all levels of any hierarchy is always unique
Keeping these in mind there are a few conditions we would need to take care of:
· There can be a few skip level of hierarchies as a result of analysis
This can be taken care of because of the property that each set of hierarchy level is always a unique set. So if a level is ‘All’ we simply won’t pass the value of that level to the detail report.
· The detail report could be called from any level of the master report
Like above, we would consider all unselected lower levels of the hierarchy as ‘All’.
Now, there is no in built function available in WebI that can decipher the hierarchy level of the selected value. There is a function called ‘drillfilters()’ but that skips the vales when a level is selected as ‘All’ and hence cannot be used effectively. By looking at the value of this function we would not be able to determine which level is skipped.
So, to effectively design a hyperlink to the detail report we have to know the following at any given point in time:
· Selected level of hierarchy – to determine what levels to skip
· Selected value of hierarchy
Enough of describing the problem let us now work on the solution. I would like to put a solution statement here so that we start looking at the problem from a different angle.
Solution Statement:
Create a hyperlink that will pass all the relevant information to run the detail report from a master report with drill.
Create a variable in the master report for each of the hierarchy level. These variables will equate at each display row level and would be used to build the hyperlink. So in our case, we will have the following variables:
v_CheckCountry = if (Max (Count ([Country of origin])) = 1; [Country of origin]; “”)
v_CheckRegion = if (Max (Count ([Region])) = 1; [Region]; “”)
v_CheckCity = if (Max (Count ([City])) = 1; [City]; “”)
v_CheckCust = if (Max (Count ([Customer])) = 1; [Customer]; “”)
count() function determines if that dimension is at the lowest level in the hierarchy at any point in time. If the dimension is at the lowest level then it returns 1. Or else display nothing which equates to passing a NULL to the detail report for the dimension.
max() function is applied to make sure the data row for a dimension is at the lowest level.
This is how the variables would work in runtime with different set of selected drill values. On top is the sample data (US only). On left in the If column is the selection scenarios. Drill dimension is the dimension that a use would see in the report block during normal drill navigation. Rest of the columns displays the output of the v_function functions. The v_function will not be required to be available in the report layout, but will provide the values for the hyperlink at each row level. These four values from the v_function will be passed as prompts to the detail report.
Explanation of a few scenarios based on the sample data. You would be able to guess the rest.
1. When nothing is selected; all v_CheckXXX will return more than 1 row as count except the starting level of dimension. So when you click on the link by ‘US’ the prompt values passed to the detail report would be:
Prompt
|
Value
|
Country
|
US
|
Region
|
NULL
|
City
|
NULL
|
Cust
|
NULL
|
2. When you drill down on ‘US’, the regions would be visible. So when you click on the link by ‘East Coast’ the prompt values passed to the detail report would be:
Prompt
|
Value
|
Country
|
US
|
Region
|
East Coast
|
City
|
NULL
|
Cust
|
NULL
|
And when you click on the link by ‘Mid West’ the prompt values passed to the detail report would be:
Prompt
|
Value
|
Country
|
US
|
Region
|
Mid West
|
City
|
Chicago
|
Cust
|
Baker
|
In this case you would say that the City and Customer values are passed to the detail report unnecessarily, but they are passes as there is only one city and one customer for ‘Mid West’ and hence it would not affect the data fetched in the detail report.
3. When you drill down on ‘East Coast’, the city would be visible. So when you click on the link by ‘Washington D.C.’ the prompt values passed to the detail report would be:
Prompt
|
Value
|
Country
|
US
|
Region
|
East Coast
|
City
|
Washington D.C.
|
Cust
|
Swenson
|
4. At this step we drill down to cities for ‘New York City’. Let’s skip to #5
5. Now let’s select ‘All City’ in the City drill filter drop down. This will show all the cities in ‘East Coast’. So when you click on the link by ‘Brendt’ the prompt values passed to the detail report would be:
Prompt
|
Value
|
Country
|
US
|
Region
|
East Coast
|
City
|
New York City
|
Cust
|
Brendt
|
6. Let’s skip this one; as by now you would have got the idea.
The observation here is that irrespective of what is displayed, the link is always going to pass the correct prompt combination for any selected drill dimension at any level of the drill.
Now let’s create the hyperlink. I personally like the method of directly creating them as functions:
v_Hyperlink_To_Detail ="<a "+[opendoc with TargetRefresh]+ "&sDocName=Detail Report
&lsS Enter Country:=" + URLEncode([v_ CheckCountry]) + "
&lsS Enter Region:=" + URLEncode([v_ CheckRegion]) + "
&lsS Enter City:=" + URLEncode([v_ CheckCity]) + "
&lsS Enter Customer:=" + URLEncode([v_ CheckCust]) + "' > " + "Link" + "</a>"
Add this variable v_Hyperlink_To_Detail in the report block of master report and you would be able to now drill to the relevant detail report with the correct data based on any combination of drill level or drill filters applied.
That’s all folks… Happy linking…