Issues with my dataset mapping or my sumover logic - need guidance

Hi @andreduarte

You are not doing anything wrong in the expression itself your dataset grain is the issue.

All rows in your visual are at the claim * procedure * payment/adjustment level. So, each charge row is duplicated once for every payment/adjustment row. sumOver(charges, [{claim_id}], PRE_AGG) just sums all those duplicated values, so you get 130 * 8 = 1040.

If charges is constant per claim (or per claim+procedure), use a min/max at the claim level instead of sumOver.

Example:

ClaimCharges = maxOver({totalcharges}, [{claim_id}], PRE_AGG)

ClaimPayments = sumOver({paymentamount}, [{claim_id}], PRE_AGG) / distinct_countOver({payment_id}, [{claim_id}], PRE_AGG)

1 Like