KNOWLEDGE BASE

How To Calculate A Measure Based On The Accumulation Of Other Measures


Published: 22 Jun 2020
Last Modified Date: 22 Jun 2020

Question

How to calculate the stock numbers of each day based on the numbers of purchase, sales and shipment?
*stock numbers=purchase numbers -sales numbers -shipment numbers 

Environment

  • Tableau Desktop

Answer

1. Create a calculation field [Stock] as the following:
(zn(SUM([Purchase]))-zn(SUM([Sales]))-zn(SUM([Shipment])))+PREVIOUS_VALUE(0)

2. Drag dimension [date] to Rows, set it to MDY(date)
3. Drag [Stock] to Text
4. Edit Table Calculation to Compute Using Month, Day, Year of date
Did this article resolve the issue?