Hi @andreduarte,
When you say different tables, do you mean that your data is split up between multiple datasets?
When you’re using max, you shouldn’t be summing any numbers, it should just be pulling the max amount (so if there are multiple rows for one Claim ID and there ‘charge’ is the same, it will just take that amount instead of a total for all).
When trying out, what’s the sum value you get that is incorrect?
I have a left join between claim, charges and payments. I believe that this is returning multiple charges rows per claim and leading to the issue. I was able to use sumif(claim_charge, payer_level = 'primary) and it solved the problem. Thanks for your help.