You're on the right lines, but that is a bit messy.. ;)
Firstly, you need to create two separate columns to count the times the player made the action, and the times they had the opportunity to make the action.
For both you're trying to count how many times a certain situation happens, so you need to structure the expression like this:
sum( if[ expression, 1, 0 ] )
That says: if the expression is true for this hand add 1, if not add 0. This will be done for every hand, so count up the number of hands for which the expression was true.
Some detail:
substring(lookup_actions_f.action from 1 for 1 AND if holdem_hand_player_statistics.flg_t_bet='X', 1, 0])
..won't work.
You need to compare:
substring(lookup_actions_f.action from 1 for 1) with something: e.g. substring(lookup_actions_f.action from 1 for 1) = 'X'.
An easier way to do this is to use LIKE:
lookup_actions_f.action LIKE 'X%'
..means that the first character was X (check). Here, though, you want to see if the flop actions were check only, so you can just use =.
lookup_actions_f.action = 'X'
holdem_hand_player_statistics.flg_t_bet is a boolean value (true or false), so you can't compare it with a string.
Let's ignore position initially, as that complicates things further - let's just count times the player bet the turn when the flop was checked through. We can come back and add more detail later.
Since you used "holdem_hand_player_statistics.cnt_p_raise > 0" I guess you want this for raised pots only, but you probably want hands where the player faced a raise, rather than making the raise themself? That would be holdem_hand_player_statistics.flg_p_face_raise.
cnt_t_bet_after_flop_checked =
sum( if[ holdem_hand_player_statistics.flg_p_face_raise AND lookup_actions_f.action='X' AND lookup_actions_t.action='B%', 1, 0 ] )
cnt_t_open_opp_after_flop_checked =
sum( if[ holdem_hand_player_statistics.flg_p_face_raise AND lookup_actions_f.action='X' AND holdem_hand_player_detail.flg_t_open_opp, 1, 0 ] )
Please read the
Tutorial - Custom Reports and Statistics for more detail and for how to display these columns in a stat.
Use of actions strings (LIKE, etc) is described there, as well as the general structure of stats, etc.