Hello Jan Paulo,
See the attached example workbook (you didn't mention version of Tableau so this is version10).
I created the following:
if sum([Resposta Realizada])>0 then 1 else 0 END - to show the same calculation of 1 or zero based on the value of Responsta Realizada - this gives the numerator
Then I countd the values of Loja that are unique per Categoria - window_sum(countd([Loja])) - this gives the denominator for calculation.
Then we create the combined calculation.
The table calculation functions in the view are set to utilize the filed of Loja for the Compute Using since the Categoria field acts as a Dimension to partition the values.
On the "Final Result" tab, I have thrown in one more calculation - "if first()=0 then.... " and I have done this so that we only return the percentage Reposta once per Categoria to make it look like the Excel report.
I hope this helps out.
Calculo Geral.twbx 18.4 KB