Hello Guilherme Leitão,
Is it possible to provide a small amount of sample data in a Tableau .twbx file to share with the community and one example of the output expected? I think what you want is pretty easy but seeing some data and an example of what you believe is the 'answer' will help us to help you.
Oh - and please let us know the version of Tableau that you are working in.
Its a simple table
I solve the problem in my OracleDatabase, at the SQL adding the lines sum, but not at the TABLEAU
A 32 Y
B 32 Y
C 7 Y
plus the above lines, by this I add one more column just to know if it was the sum
I agree with Patrick, providing us with a sample packaged workbook or Excel file would help a great deal.