Divide a calculated field by LAC field

Hi Everyone,
I am trying to divide a non-LAC field by a LAC field, but getting an error. Is their a way around.

sum({Field1})
/
sum({Field1}, [{Field2}])

Background: I am trying to build a stack 100 % bar chart, but it acts weird for tooltip fields as mentioned here. So to overcome this issue, I am building calculated fields that will add upto 100%.

In this bar chart I have Product on the y-axis and each group/color is a Segment.

I was able to calculate a percentage as follows:
(sumOver(Sales, [Product, Segment], PRE_AGG) / sumOver(Sales, [Product], PRE_FILTER)) * 100

I don’t see a way to format the value in the tooltip as a percentage, so as a workaround, I multiplied it by 100.

image

2 Likes

Hi @Karan_Chhabra ,

I’m marking @David_Wong 's response as solution to your question.
Will add on that you don’t necessarily need to multiply by 100. You can set the format of the calculated field from the field list to have it appear as percentage.
image

Also, If you already have product and segment fields in the visual, you can do a regular sum in the numerator if you wrap the sumOver in denominator in a min function.
sum(Sales)/min(sumOver(Sales,[Product],PRE_FILTER))

Regards,
Arun Santhosh