1 2 Previous Next 16 Replies Latest reply on Oct 15, 2018 1:43 PM by tanvi khanna

# Calculating and applying weight for survey data

Hi, community!

I need your help!

Here is my situation. It's very easy for you, I know )))

1. I have a very simple survey dataset.

2. The variable "answer" holds respondent's answers and variable *** holds their's "***".

3. The distribution of participant's *** is 79% - females and 21% for males - for this survey

4. The real distribution of males and females in population is 45% - females and 55% - for males

5. I need to have a calculated field with weight, controlled by parameter: switch between "unweighted answers" and "answers, weighted by ***"

6. I'm using simple "number of records percent of total" table calculation with horizontal bars as a visualization of "answers" distribution

7. Parameter switch should affect on this visualization, changing percent distribution, according to current parameter selection.

Please, help me to solve this task!

• ###### 1. Re: Calculating and applying weight for survey data

Hi Alexander - Have you checked the Tableau Survey Data Group to see if this has been discussed there? For some reason I am unable to open your Tableau workbook.

Survey Data

• ###### 2. Re: Calculating and applying weight for survey data

I've already checked dozens of post by keyword "weight" ,"sample weighting" e.t.c. And also tags, which I used for my post. Most people already have weight variable in their dataset.
But I need to calculate it first. Calculate "on the fly".

• ###### 3. Re: Calculating and applying weight for survey data

Looks like it may have been created using Tableau 9, which is in Beta.

Can you mock up what you'd expect to see for "Weighted by ***" versus "Unweighted" -- I'm not sure I understand the logic or details you've provided thus far.

• ###### 4. Re: Calculating and applying weight for survey data

I'm sorry my friends! I've changed the attached workbook version to 8.2.

Sorry, again )))

• ###### 5. Re: Calculating and applying weight for survey data

I'll try ti show in mockups ))

2. What I need 3. The distribution of participant's *** is 79% - females and 21% for males - for this survey

4. The real distribution of males and females in population is 45% - females and 55% - for males

• ###### 6. Re: Calculating and applying weight for survey data

I've changed the workbook. Please, check!

• ###### 7. Re: Calculating and applying weight for survey data

Alexander,

The results in your workbook is the opposite of what you state above. The results are 79% male and 21% female.

Based on what you stated, rather than the values in the workbook you could do something like this:

Males are under counted and females are over counted. you can normalize the population by doing a calculating a scaling factor. Instead of using 1 (Number of Records) for all records, use 2.619048 (.55/.21 ) for males and 0.56962 (.45/.71) for females.

Create a calculated field

if [***] = 'male' then 2.619048

else 0.56962

end

or

iif([***] = 'male', 2.619048, 0.56962)

Sum that calculated field to get the results.

you could use a calculated field to substitute Number of Records for the new calculated field based on a parameter like you showed above.

Jeff

1 of 1 people found this helpful
• ###### 8. Re: Calculating and applying weight for survey data

Hi,

Hope this helps.

1 of 1 people found this helpful
• ###### 10. Re: Calculating and applying weight for survey data

Thank, you Jeff!

The same final question to you:
How can I avoid of manual entering .21 and .79 parameters for my sample?. Is there a way to calculate it using formula?

My dataset is changing time over time, because the survey is in progress and I use live database connection...

• ###### 11. Re: Calculating and applying weight for survey data

Smb., please! Help me with this issue!

• ###### 12. Re: Calculating and applying weight for survey data

I'm running into issues due to which i have to rethink the whole process. Let me try out in 9.0 using LOD calculations and will get back incase i get it.

• ###### 13. Re: Calculating and applying weight for survey data

Hi Alexander - Can you clarify how you determined 79% females and 21% males from the survey data? I see that there are separate rows of data for Survey Answer 1, 2 and 3 along with Gender.

For example, are we to assume that each row in the data corresponds to a different individual? i.e. Male % = (Count of rows with Gender = "male") / (Total Number of Records)?

Or could one individual provide one or more answers? i.e. does the survey gender % need to be calculated separately for each "Answer" and then weighted by the 55% - 45% male/female ratio?

• ###### 14. Re: Calculating and applying weight for survey data

Hope this helps.

I thought of using Tableau 9, but it was not as complex as i thought. So have a look at the solution in Tableau 8 and let me know. Pardon the excessive steps i took for the calculation. I guess this can be done a lot easier in a single formula.

1 2 Previous Next