Your survey is not your population
Surveys rarely reach the people they are meant to describe in the right proportions. Retired residents answer the phone, students do not. Commuters with strong opinions click the link, people who are merely satisfied ignore it. The result is a sample that leans toward some groups and away from others, and every headline number you calculate from it inherits that lean. Survey weighting is the standard way to correct it, and the first step is always the same: compare the sample with the population and measure the gaps.
This course is for market researchers, public-sector analysts, students writing a thesis with questionnaire data, HR teams running employee surveys, and anyone who has to report "x% of customers are satisfied" from a sample. You will build every step of a weighting scheme in Excel: post-stratification, raking by iterative proportional fitting, trimming, weighted estimates, the design effect and a weighted margin of error. No statistics package is needed. This free first lesson does the groundwork that every one of those steps depends on: the margin comparison.
The lab uses the fictional Lakemoor Regional Transit Authority, which interviewed 1,200 adults about buses and trams. The region has 640,000 adults according to a (synthetic) census. Older residents and suburban commuters answered eagerly, young adults did not. All data is invented for practice.
The core concept: margins, gaps and a first-guess weight
A margin is the distribution of one variable on its own: the share of each age group, the share of women and men, the share of each region. You need the margins of the sample (from your interviews) and of the population (from a census, a register or another trusted source). Comparing them variable by variable answers three questions:
- Sample share = interviews in the group ÷ all interviews (n). For 18–34 year olds: 228 ÷ 1,200 = 19.0%.
- Population share = adults in the group ÷ all adults (N). For 18–34: 192,000 ÷ 640,000 = 30.0%.
- Gap = sample share − population share, in percentage points. For 18–34: 19.0% − 30.0% = −11.0 points. A negative gap means the group is missing from the sample, a positive gap means it is over-represented.
From the two shares you also get a first-guess weight: population share ÷ sample share. For 18–34 that is 30.0% ÷ 19.0% = 1.58, which means each young respondent has to speak for 1.58 "average" respondents if the age distribution is to match the population. Groups with a ratio below 1 get weighted down: each person aged 55+ counts as 0.76 of a respondent. Note that this is a relative weight that averages to 1 across the sample. Multiply it by N ÷ n (here 640,000 ÷ 1,200 ≈ 533) and you get an expansion weight, the number of adults each interview represents.
One ratio per variable is not yet a weighting scheme, because a person is young and a woman and lives in the city at the same time. Combining the margins correctly is what post-stratification and raking do later in the course. But the ratios already tell you where the work will be, and a ratio far above 1 is an early warning: it means a small, hard-to-reach group will carry a lot of weight, which increases the variance of every estimate.
Choosing the variables to compare
Which variables should you compare? Good weighting variables meet three conditions. First, reliable population figures exist for them, from a census, a register or your own customer or employee database. Second, they were asked in the survey in exactly the same categories, so that "35–54" means the same thing in both sources. Third, they are related to the topics of the survey or to the willingness to answer. Age, gender and region are the classic trio because they meet all three conditions in most countries. Education, household size or, for customer surveys, plan type and tenure are common additions.
Fewer, well-measured variables are usually better than many. Every extra variable adds categories, and categories with only a handful of interviews produce large and unstable weights. That is why the lab keeps three variables with two or three groups each. When you design your own survey, decide on the weighting variables before fieldwork, so that the questions are worded to match the population source and every respondent answers them.
Worked example: the Lakemoor transit survey
Here are all eight groups from the lab. Each variable block (age, gender, region) adds up to the same 1,200 interviews and the same 640,000 adults, which is why one n in C13 and one N in D14 are enough for every row.
| Variable | Group | Interviews | Adults (census) | Sample share (E) | Population share (F) | Gap, points (G) | Pop ÷ sample (H) |
|---|---|---|---|---|---|---|---|
| Age | 18–34 | 228 | 192,000 | 19.0% | 30.0% | −11.0 | 1.58 |
| Age | 35–54 | 432 | 230,400 | 36.0% | 36.0% | 0.0 | 1.00 |
| Age | 55+ | 540 | 217,600 | 45.0% | 34.0% | +11.0 | 0.76 |
| Gender | Women | 708 | 329,600 | 59.0% | 51.5% | +7.5 | 0.87 |
| Gender | Men | 492 | 310,400 | 41.0% | 48.5% | −7.5 | 1.18 |
| Region | City | 456 | 281,600 | 38.0% | 44.0% | −6.0 | 1.16 |
| Region | Suburbs | 516 | 230,400 | 43.0% | 36.0% | +7.0 | 0.84 |
| Region | Rural | 228 | 128,000 | 19.0% | 20.0% | −1.0 | 1.05 |
Reading the table from top to bottom: the age margin shows the biggest imbalance, 18–34 year olds are 11 points short and people aged 55+ are 11 points over. The 35–54 group happens to match exactly, so its ratio is 1.00. Women are over-represented by 7.5 points, a pattern many survey teams see in practice. In the regions, suburbs are 7 points over and the city is 6 points short, while rural residents are almost on target. The most under-represented group, the answer to the lab's last task, is 18–34 with a ratio of 1.58.
Why does this matter if the questions are about buses, not about age? Because opinions usually differ between groups. Suppose, for example, that 55% of 18–34 year olds, 65% of 35–54 year olds and 78% of people aged 55+ are satisfied with the service. These rates are assumed for illustration only. The unweighted result mixes them in the sample's proportions, a weighted result mixes them in the population's proportions:
| Age group | Sample share | Population share | Satisfied (for example) | Sample × satisfied | Population × satisfied |
|---|---|---|---|---|---|
| 18–34 | 19.0% | 30.0% | 55% | 10.5% | 16.5% |
| 35–54 | 36.0% | 36.0% | 65% | 23.4% | 23.4% |
| 55+ | 45.0% | 34.0% | 78% | 35.1% | 26.5% |
| Total | 100.0% | 100.0% | 69.0% | 66.4% |
The unweighted headline would say 69.0% are satisfied, the age-corrected figure is 66.4%, a difference of 2.5 points caused only by who answered. In Excel the two totals are =SUMPRODUCT(E4:E6,J4:J6) and =SUMPRODUCT(F4:F6,J4:J6) if the satisfaction rates sit in J4:J6. With real data the size and direction of the difference depend on how strongly the opinion is linked to the weighting variables, which is exactly why you check the margins first.
Step by step in Excel
These steps follow the lab above. They work in any recent Excel version, and XLOOKUP needs Excel 2021 or Microsoft 365.
- Check the totals. C13 holds
=SUM(C4:C6)and D14=SUM(D4:D6). Before going on, confirm that the gender rows (C7:C8) and region rows (C9:C11) also add up to 1,200, for example with=SUM(C7:C8)=C13, which should return TRUE. If a block does not add up, some respondents have a missing answer and need their own category. - Sample shares. In E4 type
=C4/$C$13. TypeC13and press F4 once to make it absolute. Select E4:E11 and press Ctrl+D to fill down. Rural (E11) shows 19.0%. - Population shares. In F4 type
=D4/$D$14and fill down to F11. Format E4:F11 as percent with Ctrl+Shift+% and add one decimal (Home → Increase Decimal). - Gaps. In G4 type
=E4-F4and fill down. The 18–34 gap is −11.0%. Excel shows a "%" sign, but read it as percentage points: the difference between two percentages. - Ratios. In H4 type
=F4/E4and fill down. Rural (H11) is 1.05. Format with two decimals, not as a percentage. - Find the group that needs the biggest weight. In B16 type
=INDEX(B4:B11,MATCH(MAX(H4:H11),H4:H11,0)), or in Microsoft 365=XLOOKUP(MAX(H4:H11),H4:H11,B4:B11). Both return 18–34. - Make the gaps visible. Select G4:G11 and choose Home → Conditional Formatting → Data Bars. Excel draws negative bars to the left of an axis, a quick in-cell version of the gap chart above.
- Sanity check.
=SUM(E4:E6)and=SUM(F4:F6)must both be 100%, and so must each other block. The sum of gaps within a block is always 0.
Common mistakes and how to spot them
Margin comparisons look trivial, but small slips here propagate into every weight you build later.
- Ratio upside down. Sample share ÷ population share gives 0.63 for 18–34, which would weight young people further down. How to spot it: a group that is missing from the sample must get a ratio above 1.
- Gap with the wrong sign. Population − sample flips every sign, so missing groups look over-represented. How to spot it: 18–34 must show a negative gap, since they are fewer in the sample than in the population.
- Relative references on the totals.
=C4/C13filled down becomes=C5/C14, which divides by an empty cell and shows #DIV/0!. How to spot it: errors or 100% values from row 5 on. Use$C$13. - Blocks that do not add up. If some respondents did not state their age, the age block sums to less than 1,200 and the shares are off. How to spot it: check every block total against n, and add a "not stated" row instead of dropping people silently.
- Mismatched definitions. A census that counts adults aged 18+ cannot be compared with a survey of people aged 16+, and region boundaries must be the same in both sources. How to spot it: write the definition next to each population figure and compare.
- Treating weighting as a cure-all. Weighting corrects the variables you weight on, and helps with others only to the extent that they are related. If satisfied passengers were simply more willing to answer within every age group, weighting by age does not fix it. How to spot the risk: compare weighted results with any outside benchmark you have.

Quick reference: formulas and shortcuts
Everything used in this lesson, ready to copy:
| Function / tool | What it does here | Example |
|---|---|---|
SUM | Total interviews n and total adults N | =SUM(C4:C6) → 1,200 |
Absolute reference $C$13 | Keeps the denominator fixed while you fill down; press F4 to toggle | =C4/$C$13 |
| Share | Group count ÷ total | =D4/$D$14 → 30.0% |
| Gap | Sample share − population share | =E4-F4 → −11.0 points |
| Ratio | Population share ÷ sample share, the first-guess weight | =F4/E4 → 1.58 |
INDEX + MATCH | Name of the group with the largest ratio | =INDEX(B4:B11,MATCH(MAX(H4:H11),H4:H11,0)) |
XLOOKUP (365/2021) | Same lookup in one function | =XLOOKUP(MAX(H4:H11),H4:H11,B4:B11) |
SUMPRODUCT | Share-weighted average of a result | =SUMPRODUCT(F4:F6,J4:J6) |
| Data Bars | Visual gap column | Home → Conditional Formatting → Data Bars |
| Percent format | Show shares as % | Ctrl+Shift+% |
| Fill down | Copy the top formula into the selection | Ctrl+D or double-click the fill handle |
Real-world uses
Margin comparisons and first-guess weights come up wherever results from a sample are reported for a whole population:
- Customer satisfaction surveys. Compare respondents with the customer base by segment, region or plan type from your CRM. If premium customers answer twice as often, the unweighted score describes them more than your customers overall.
- Employee engagement surveys. HR has the exact headcount per department and location, so the population margins are known. A department that answered at 30% while others answered at 80% will be under-represented in the company-wide score.
- Public consultations and transit surveys. Agencies compare respondents with census figures on age, gender and district before publishing, much like the Lakemoor example.
- Student and thesis research. A gap table belongs in the methods chapter: it documents how the sample differs from the population and justifies the weighting that follows.
- Online panels and polls. Opt-in samples often have large gaps on age and education. The ratio column shows quickly whether some groups would need extreme weights, which is a warning about how much the results can be trusted.
What you will build in the rest of this course
The free lesson tells you how far the sample is from the population. The remaining 19 lessons turn that into proper weights, apply them and measure what weighting costs in precision. They are part of the paid course, a one-time purchase of $9.90, and each one is a lab on the same Lakemoor survey, so the numbers carry through from lesson to lesson.
Cell Weighting: Post-Stratification on Age × Region. You will build expansion weights and relative weights for nine age × region cells, check that the weighted sample still adds up to 1,200 interviews, and find the cells whose weights are large enough to be risky.
Raking by Iterative Proportional Fitting (IPF): Two Margins, Four Steps. When you only know the margins, not the joint table, raking is the standard answer. You will rake a 3 × 3 table to the age margin and the region margin in turn, watch the totals converge after two rounds and read off a raked weight.
Weight Trimming & Capping: Limits, Rescaling and Who Is Affected. Large weights make estimates unstable. You will cap raked weights at 0.5 and 2.5, rescale them so they add up to 1,200 again, and count how many interviews the trimming touched.
Weighted Estimates with SUMPRODUCT vs Unweighted Results. This is where weights change the answers. You will calculate weighted means and shares from respondent records with SUMPRODUCT, including a weighted share for one region, and compare them with the unweighted numbers.
Kish Effective Sample Size & Design Effect: Raked vs Trimmed Weights. Weighting has a price. You will compute Kish's effective sample size and the design effect for the raked and the trimmed weights, and see how many effective interviews trimming wins back.
Weighted Margin of Error: z, √deff and Subgroups. You will calculate the textbook margin of error, widen it with the square root of the design effect, repeat it for the small rural subgroup and report the upper end of the interval, the way a careful survey report should.
Before vs After Weighting: Gap Table & Comparison Chart. Lab 8 closes the loop: weighted shares, the absolute gap to the population before and after weighting, and a chart of population, sample and weighted shares side by side that shows the effect of the whole scheme at a glance.
Summary
Before you weight a survey, compare its margins with the population. Sample share = group ÷ n, population share = group ÷ N, gap = sample − population in percentage points, and population share ÷ sample share is the first-guess weight. In the Lakemoor survey, 18–34 year olds are 11 points short and need a weight of about 1.58, while people aged 55+ are 11 points over and get 0.76. Because opinions differ between groups, these gaps can move a headline result by several points.
Scroll up to the lab and build the comparison yourself: sample shares, population shares, gaps, ratios and the most under-represented group. The Coach checks each step, and it takes about 15 minutes.
Frequently asked questions
What is survey weighting?
Survey weighting gives each respondent a weight so that the weighted sample matches known population figures, such as the shares of age groups or regions. It corrects for groups that answered more or less often than their share of the population.
How do you calculate a survey weight in Excel?
The simplest weight for one variable is population share divided by sample share, for example =F4/E4. A group that is 30% of the population but 19% of the sample gets a weight of about 1.58.
What is the difference between post-stratification and raking?
Post-stratification weights cells of a joint table, such as age × region, to known cell totals. Raking (iterative proportional fitting) adjusts weights to several margins in turn when only the separate margins are known.
What does a negative gap between sample and population mean?
If the gap is calculated as sample share minus population share, a negative value means the group is under-represented in the sample. It will need a weight above 1.
Where do population margins for weighting come from?
Typically from a census, an official population register, or for customer and employee surveys from your own CRM or HR system. The definitions, such as age limits and region boundaries, must match the survey.
Does weighting remove all bias from a survey?
No. Weighting corrects imbalances on the variables you weight on and on characteristics related to them. If people with different opinions answer at different rates within the same group, weighting cannot fully correct it.
Keep going: Survey Weighting: Post-Stratification, Raking (IPF) & Design Effects
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time $9.90.
- Cell Weighting: Post-Stratification on Age × Region
- Raking by Iterative Proportional Fitting (IPF): Two Margins, Four Steps
- Weight Trimming & Capping: Limits, Rescaling and Who Is Affected
- Weighted Estimates with SUMPRODUCT vs Unweighted Results
- Kish Effective Sample Size & Design Effect: Raked vs Trimmed Weights
- Weighted Margin of Error: z, √deff and Subgroups
- Before vs After Weighting: Gap Table & Comparison Chart
- Base Weights: Selection Probabilities, One Adult per Household and a Cap
- Nonresponse Adjustment: Response Rates by Class and Adjustment Factors
- Raking to Three Margins: Age, Gender and Region on a Cell List with SUMIFS
- Raking Convergence: Iteration Log, Tolerance and a Gap Chart
- Sparse Cells: Minimum Cell Size and Collapsing Before Weighting
- Trimming in Rounds: Trim, Rescale, Repeat Until the Limits Hold
- Weight Diagnostics: Spread, CV, Top-Weight Share and a Weight Histogram
- Weighted Cross-Tabs: Weighted Counts, Row Percentages and Unweighted Bases
- Weighted Medians and Percentiles from Sorted Respondent Records
- Replication Variance: Delete-a-Group Jackknife Standard Errors
- Choosing a Weighting Scheme: Bias, Precision and Total Error Against a Benchmark
- Final Project: Weighting Report Dashboard for a New Survey Wave