# Collections and Pie Charts

Hello everyone, again.

I’ve installed the Chart Kit and now I am trying to make a simple cost x category Pie Chart.

These are my Collections:

User > Projetos > Lancamentos > Categorias.

Each Lancamento have a vl_lancamento ( money/amount ).

I want to show display a Pie Chart showing sum(lancamento.vl_lancamento) grouped by Category, so I users will know where they are spending most of their Money.

I’ve tried many combinations but so far it didn’t work well.

For this Projeto ( Project ) the Amount by Category is

Ferragens: 1,000.00
Fundaçao: 15,000.00
Acabamento: 150.00

The Pie Char would some something near to

Ferragens: 6%
Fundaçao: 92%
Acabamento: 1%

What I am doing wrong ?

Márcio

Hey there @marcio

For the “Value” field, you need to add a custom formula to calculate the percentage rather than the total.

Delete your current Slice Value sum.
Add > Current Projecto Lancamentos > Sum DIVIDED by All Projecto Lancamentos > Sum MULTIPLY by 100.

So for Ferragens, you’d have 1,000 divided by 16150 = 0.061919504643963 * 100 = 6.19%

You may use the INT function to remove the extra decimal points if the pie chart doesn’t do it automatically.

Hello @Flawless,

Good to know I can do some math in the Value field… I thought I could only set the attributes.

Yet, I tried your suggestion, but it didn´t work well… Also, note that I am grouping only the Lancamentos under the one Project I am under, not ALL lancamentos at all. I think what I am missing is how my Project Lancamentos can be grouped by Categories.

Thank you,

Márcio

Hi @marcio,

Can you include some screenshots of your collections with example data?

Thank you

Hello @dilon_perera sure thing…

I’ve performed a DB cleanup so I can start over with simplified data…

Here we go.

I have only two Projects now:

1st Project ( Casa Nova ), Lancamentos

2nd Project ( Galpao CP ), Lancamentos

I just checked the 2nd Project Pie Chart and it shows 50/50. But this is not right… it is saying half is “Acabamento” and the other half is “Ferragens”. It is clearly counting the categories rather the Amount.

Pie Chart Settings… after many attempts and back-and-forth is

Thank you all for your time and assistance.

Márcio

Correct?

Hello @dilon_perera that is about right ! So the key was to run the Pie Chart in the Categories, rather the Lancamentos… I see it.

I will try your approach later today and let you know how it goes… Of course, if it works for you it must work for me.

Again, I cannot thank you enough for all the time you put on recreating my app and recording this video.

Regards,

Márcio

Hello @dilon_perera This worked like a charm man ! Thank you very much.

I also saw what you´ve done with the Add Filter on the Slice Value… I think this made all the difference from when I previously tried the Chart on the Categories as well… It was bringing all Projects categories. The fileter narrowed it down to the current project only… Got it.

Thank you again.

1 Like