How are rollup values calculated for groups?
Assuming I have a data file that looks like:
Industry,Symbol,Market Cap
Technology,MSFT,57.6
Technology,ORCL,43.4
Technology,APPL,12.1
And then I use the <hierarchy type="group" field="Industry" /> to create a grouped
hierarchy. Now when I look at the MSFT leaf-level stock, I can use any of the following
syntaxes to access the value of the "Market Cap" field:
${data['Market Cap']} 57.6
${data['Market Cap']@source} 57.6
${data['Market Cap']@rollup} 57.6
Say I hover over the "Technology" group using the same expressions in my popup panel. Now
my values look like:
${data['Market Cap']} 113.1
${data['Market Cap']@source} null
${data['Market Cap']@rollup} 113.1
Because the "Technology" element does not exist as a row in the source data file, it's
source attribute is null. The rollup attribute sums the values of all the
children (MSFT, ORCL, APPL). Finally, if I don't specify an attribute, the default is to first
check for a source attribute and if that is null, use the rollup attribute,
which is why this returns the same value as the rollup expression.
Okay, so let's assume you are using the parent-child hierarchy instead of doing group bys,
and you are explicitly including the value for Technology in your data file:
Key,Parent,Name,Market Cap
^Tech,,Technology,120.8
MSFT,^Tech,MSFT,57.6
ORCL,^Tech,ORCL,43.4
APPL,^Tech,APPL,12.1
Now, the MSFT leaf level stock will display the same information as above, but when you
hover over the Technology group, you'll get:
${data['Market Cap']} 120.8
${data['Market Cap']@source} 120.8
${data['Market Cap']@rollup} 113.1
In this case, the explicit value you gave is displayed if you don't specify you want
the rollup value.
If you are using Microsoft Reporting Server and including the values it calculates as
the rollup values in the data file, then you could see a discrepancy between these two if
it is using a different type of rollup algorithm than a straight sum rollup.
Okay, so I think that's the question you were asking. But just in case, let me explain
how you access values of the children.
Let's say you want to show the value of the first child underneath a given cell. So,
say you want to display the information for MSFT *while* you are hovering over the
Technology cell. In this case, you can use the child syntax:
${node.child[0]['label']}: ${node.child[0].data['Market Cap']}
When you are hovering over the Technology cell, this will now resolve to:
MSFT: 57.6
You can also use the source and rollup value here too. So, assuming MSFT
had child cells too, then you could use:
${node.child[0].data['Market Cap']@rollup}
To get the rollup value.
Essentially, the ${data} expression, is a simplification of ${node.data}. So:
${node.data['Market Cap']}
${data['Market Cap']}
Are semantically equivalent. But since "node" refers to the currently focused node, you
can also access levels above and below the node when you use this syntax. The child example
you've already seen, but you can also use:
${node.parent.data['Market Cap']}
Which displays the parent value for the "Market Cap" field.
|