I used below logic to get the numbers.
Assumption:
Ending CI for Any Quarter= Ending CI Previous Quarter + SI Current Quarter - ST Current Quarter
Let me know if this is incorrect as CI Ending Numbers in your snapshot do not tie up with the logic.
Logic Used: This would show Ending CI if available, when it is not available show it based on logic.
ifnull(sum([Ending CI]),
PREVIOUS_VALUE(sum([Ending CI]))+ sum([SI Units])-sum([ST Units]))