How to create a custom average 3bet size stat?

I created a player column stat
val_p_total_3bet
sum(if[cash_hand_player_statistics.flg_p_3bet, cash_hand_player_statistics.amt_p_raise_made_2 / cash_limit.amt_bb, 0])
and a custom player stat
Avg 3Bet Size
if( cnt_p_3bet > 0, (val_p_total_3bet / cnt_p_3bet), 0 )
It gives an output but not the one I expected. Any idea what I am doing wrong?
I did similar for average rfi size
val_p_total_rfi
sum(if[cash_hand_player_statistics.flg_p_first_raise, cash_hand_player_statistics.amt_p_raise_made / cash_limit.amt_bb, 0])
Avg RFI Size
val_p_total_rfi / cnt_p_raise_first_in
This works as expected.
val_p_total_3bet
sum(if[cash_hand_player_statistics.flg_p_3bet, cash_hand_player_statistics.amt_p_raise_made_2 / cash_limit.amt_bb, 0])
and a custom player stat
Avg 3Bet Size
if( cnt_p_3bet > 0, (val_p_total_3bet / cnt_p_3bet), 0 )
It gives an output but not the one I expected. Any idea what I am doing wrong?
I did similar for average rfi size
val_p_total_rfi
sum(if[cash_hand_player_statistics.flg_p_first_raise, cash_hand_player_statistics.amt_p_raise_made / cash_limit.amt_bb, 0])
Avg RFI Size
val_p_total_rfi / cnt_p_raise_first_in
This works as expected.