# Standard Devation and Variance Weighted

Hi All,

I'm stucked to perform standard deviation and variance for weighted case. This is the formula i get from wikipedia

To calculate standard deviation, I create an calculated field like this:

sum([Weight]*(([Variable]-[Mean Score - Variable])^2))

/

SUM([Weight])

but it always come with "Cannot mix aggregrate and non-aggregrate" things..

Is there's any other solution for this case?

Thanks

Randy

• ###### 1. Re: Standard Devation and Variance Weighted

RAndy

tableau has its own built in calculations, including stndard deviation. when you drop you measure right click and change your default aggregation to other measure as you need. Also there is another option. There is summary card option In Worksheet tab/Show summary. I hope it helps.

• ###### 2. Re: Standard Devation and Variance Weighted

This is link to show summary if it works for you: Summary Card

If it doesn't help you then you may want to use ATTR () in front of your each non aggregate field. Try it if it doesn't work please post your mock data.

• ###### 3. Re: Standard Devation and Variance Weighted

Like I said before, if you right click your measure then you have following options:

• ###### 4. Re: Standard Devation and Variance Weighted

Thank you for feedback

I'm quite aware of tableau feature to calculate sum, stdev, var, etc. But I believed that feature cannot be used for weighted data, because to average, standard deviation or variance between weighted and unweighted data has totally different formula.

Any other solution?

Thanks

Randy

• ###### 5. Re: Standard Devation and Variance Weighted

Randy

can you please post your sample data and how you tried to get formula with error message. We maybe able either fix your formula or get another calculation

• ###### 6. Re: Standard Devation and Variance Weighted

Pelase find .twbx file for my example case.

Randy

• ###### 7. Re: Standard Devation and Variance Weighted

I am getting several different numbers based on where I place (), so would be able to post what your final numbers should be for Imagery, right. Thanks

• ###### 8. Re: Standard Devation and Variance Weighted

Sorry for very late post, I'm kind of stuck to get the standard deviation weighted for my example, even using another apps. Would you mind to share your formula? I will confirm it with my original data.

Thanks

Randy