Creating a data expression to calculate categories' percentage shares of total amount

09-21-2023 05:04 PM
Labels (1)
New Contributor III

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,
        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(
        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.

0 Replies