8 Replies Latest reply on Jun 26, 2018 11:58 PM by Mavis Liu

# Total sum is not correct

Hello everybody,

I am having trouble with the total sum in the project I am working in.

I have this calculated filed in measures:

IF SUM([Sales])>0 THEN ([Sales])
ELSE ([Budgeted Sales])

END

I would like to show for every day of the month either the sales that were done, either the budgeted sales ( starting today I have no sales yet).

Every day I have the correct numbers. But when I add the total, it ads up just the sales. (I believe tableau just looks at the global picture, and sees that I have sales that month and gives me the first part of the formula)

Do you have any suggestions for me ? I would like for it just to add the rows that represent every day of the month.

• ###### 1. Re: Total sum is not correct

Hi,

It looks like your calculation is an aggregate. When calculating the total only the first line of your calculation is true.

Based on your question and the info supplied, I'm not able to give you a solution.

Perhaps share your workbook or a sample of your (mock)data?

g.r

Matthijs

• ###### 2. Re: Total sum is not correct

Hi Ana,

Do you have a sample workbook that you could provide us and walk us through the issue using that?

From your calculation, it looks like it won't work because you have sum(sales) as your condition, but the outcome of sales and budgeted sales are not aggregated.

Thanks,

Mavis

• ###### 3. Re: Total sum is not correct

Hello,

Thank you all for your quick answers. I have attached a mock data of my data base. Hope this will explain better my question. In the example I assumed today is the 3rd of June 2016 and thus no sales.

In tableau I wish to see, for every day of the month, either the sum of sales for the days that have passed, either the sum of budgeted sales starting today. And at the end I'd like to  have a total of all that.

Hope I clarified a little my question.

• ###### 4. Re: Total sum is not correct

Hi Ana,

Please see attached workbook, I have used the calculation:

if [Date]<#03-06-2016# then [Sales]else [Budget]

END

You can replace the #03-06-2016# with today ()

Rather than providing a screenshot of the data, please provide the excel/csv file. It'll be easier for us to use.

Thanks,

Mavis

1 of 1 people found this helpful
• ###### 5. Re: Total sum is not correct

Hi Ana

IF SUM([Sales])>0 THEN ([Sales])
ELSE ([Budgeted Sales])

END

As you are using sum(Sales) for comparison, total would always have +ve number. In order to get correct total

you should change logic as

IF [Sales]>0 THEN ([Sales])
ELSE ([Budgeted Sales])

END

Remove the aggregation.

1 of 1 people found this helpful
• ###### 6. Re: Total sum is not correct

Hi Ana,

Adding on to my previous response, please try this calculation as it would work better for your case:

Please see attached workbook.

Thanks,

Mavis

1 of 1 people found this helpful

• ###### 8. Re: Total sum is not correct

Hi Ana,

If my previous answer has answered your question, please could you mark my response as correct so that the status of this thread can be updated to 'Answered'.

You can do this by opening up the thread, unfortunately you cannot mark it as answered within your inbox.

Thanks,

Mavis