Can you please attach a workbook with what has been attempted. This helps the community assist with questions. Packaged workbooks: when, why, how
I would check out the following sections of the Online Help Guide about use of Tableau's Table Calculation
Hope this helps!