My dashboard includes a100% stacked bar chart for revenue categories. The hover text currently displays the dollar amount of each category bar.
The client wants the hover text to instead display each category's percentage of total revenue. It appears that requires a data expression.
So, consulting this post, I've set out to create a data expression that defines a variable of total revenue by month and type (actual or forecast), and uses that to generate a percentage for each revenue category.
I'm able to get total revenue by month and type with the following:
var tot_val= GroupBy( fs,
['month_year_x','type'],
[{
name:'total_rev',
expression:'value',
statistic: 'SUM'}]);
But I get an error message when I try to use the above variable in a subsequent section of code to calculate a revenue source's percentage of the total.
return GroupBy(
fs,
['rev_category','month_year_x','type'],
[{
name:'value_pct',
expression: 'value /tot_val',
statistic: 'SUM'
}
]);
The resulting serial chart would be categorized on the month_year field and split by the rev_category field. It also would include a filter so that the chart only displays "actual" numbers. Thanks.