If you use sum(total_with_A) / sum(total)
, your conditions are evaluated at the level which is displayed in your visual. That’s why you get different results in a KPI and in a table.
If you use total_with_A/total
, the conditions are evaluated at the row level.
If you want the conditions to always be evaluated at the name level regardless of the visual type, use this instead:
sumOver(total_with_A, [name], PRE_AGG) / sumOver(total, [name], PRE_AGG)