As an example, this is how I built a "Stack in BB" stat in the Holdem Cash Player Statistics section.
To calculate stack in BB we need to divide the stack size by the size of the big blind so first I built a Variable to hold each of those values.
In the custom stats window select the Holdem Cash Player Statistics section and go to the Variables tab.
(These Variables already exist in the tournament sections as they are used in the M stat.)
Click New and give the variable a name, let's start with "var_live_amt_bb".
Enter the Expression: live_table_stat( 'amt_bb' )
Add a Description too: "The BB amount in the previous hand at this table".
Add the second Variable in the same way: "var_live_amt_stack" with Expression: live_player_stat( str_player_name, 'amt_stack' ) and Description "The player's stack at the end of the previous hand".
Now that we have both the Variables that we need we can build the stat.
Go to the Statistics tab and click New.
Give your stat a Name, such as "Stack in BB", and a Description.
Enter the Value Expression using the new Variables: var_live_amt_stack / var_live_amt_bb
Although these stats won't work in reports (only the HUD) it is always a good idea to fill in the Format tab too.
Click Apply to save your stat.
If the HUD is running you will need to stop the Auto Import before your new stat is available to add to the HUD.