
1. Re: Calculate difference between table calculation and SUM()
Simon Runc Nov 23, 2017 1:45 AM (in response to Håvard Magnussen)hi Håvard,
So without seeing your workbook it's hard to give you an exact solution but hopefully the below helps...
Although we can use the quick table calculation for running sum, this is actually just a Tableau short cut for a formula (they've made the most common ones available in quick table calc). So the actual formula is
[Running Sum Sales]
RUNNING_SUM(SUM([Sales]))
so we can just create another calculation using this to get the difference
[Running Sum Sales]  SUM([Sales])
Hope that makes sense and helps...let me know if not

2. Re: Calculate difference between table calculation and SUM()
Sukhdeep Kaur Nov 23, 2017 1:52 AM (in response to Håvard Magnussen)
Testa.twbx 1.2 MB


3. Re: Calculate difference between table calculation and SUM()
Håvard Magnussen Nov 24, 2017 1:26 AM (in response to Sukhdeep Kaur)Thanks for the reply. I had sort of tried this already.
My problem is  that I of course should have mentioned  that I have two sets of data, separated out by a column "Dataset". For Dataset 1 (transaction) I need to calculate a running total to arrive at a balance. For Dataset 2 (balances), I just list the values.
So basically what I need to do is to make a conditional statement something like this:
Calculated field for dataset 1 (Transactions):
IF [DATASET]="BATransactions" THEN RUNNING_SUM(SUM([NETQC])) END
Calculated field for dataset 2 (Balances):
IF [DATASET]="BAHoldings" THEN [NETQC] END
Then in theory I should be able to do this:
Calcualated field for difference (Difference):
[Transactions][Balances]
This, however, fails miserably on the first calculated field with this error message:
"Cannot mix aggregate and nonaggregate or results in 'IF' expressions"

4. Re: Calculate difference between table calculation and SUM()
Simon Runc Nov 24, 2017 1:45 AM (in response to Håvard Magnussen)1 of 1 people found this helpfulhi Håvard,
If you want a bit about why you can't mix aggregates and non aggregates...this might help Answer  Quora
With regards your calculations, you can embed the condition inside the aggregate like this...
RUNNING_SUM(SUM(IIF([DATASET]="BATransactions", [NETQC],NULL)))
Then your variance would be something like
[Transactions] SUM([Balances])
Hope that helps

5. Re: Calculate difference between table calculation and SUM()
Håvard Magnussen Nov 24, 2017 2:29 AM (in response to Simon Runc)Thanks again.
I actually solved it myself. Created two new calculated fields. Than ran a simple SUM and a RUNNING_SUM on each separately. Then all done. But your solution with embedded condition was cool!