Tabellab
Data, tech, science & health

Raking survey weights in Excel: iterative proportional fitting step by step

Raking, also called iterative proportional fitting (IPF), adjusts survey weights so that the weighted sample matches several population margins at once, for example age and gender, without knowing how they combine in the population. You fit one margin, then the next, and repeat until all of them match. This guide rakes 1,000 interviews to an age margin and a gender margin in Excel. After three steps the largest gap is 0.18 interviews, and the raked weights range from 0.715 to 1.624.

Updated 21 Oct 2026 5 min read By Tabellab team

When you need raking instead of cell weighting

Post-stratification (cell weighting) divides the population count of each cell, say men aged 18–34, by the sample count of the same cell. It needs the joint population table. Often you only have the margins: the age distribution from one source and the gender split from another. Raking finds weights that hit every margin at the same time using only those totals, and it scales to many variables where a joint table would have hundreds of small or empty cells.

Step 1: set the targets and fit the first margin

Turn the population shares into targets on the scale of the sample: 30%, 34% and 36% of 1,000 interviews give age targets of 300, 340 and 360, and 49% / 51% give gender targets of 490 and 510. The sample has too few young people (220) and too many aged 55+ (440).

Fit the rows first: multiply every cell by its row target ÷ row sum. In Excel =B2*$E2/$D2, copied across the block. Young men go from 90 to 122.73, and each age row now adds up exactly to its target. The gender columns, 411.82 and 588.18, are still off.

Step 2: fit the second margin, then repeat

Now fit the columns: multiply every cell of the step 1 block by its column target ÷ column sum, =B8*B$6/B$11. The columns hit 490 and 510 exactly, but the rows move a little (35–54 is now 343.22 instead of 340). Fitting the rows again in step 3 brings them back, and the column gap shrinks to 0.18 of 1,000 interviews.

Each pass disturbs the previous margin less, so IPF converges quickly when no cell is empty. Real raking stops when the largest gap falls below a tolerance such as 0.001, usually after a handful of iterations. With more variables you simply fit each margin in turn inside every iteration.

Worked example: raking 1,000 interviews to age and gender

The interview counts and the targets are yellow. Each block fits one margin: step 1 the age rows, step 2 the gender columns, step 3 the age rows again. The data are synthetic.

Worked example: raking 1,000 interviews to age and gender
ABCDE
1Start: interviewsMenWomenRow sumAge target
218–3490130220300
335–54150190340340
455+170270440360
5Column sum4105901,0001,000
6Gender target4905101,000
7Step 1: fit age rowsMenWomenRow sumAge target
818–34122.73177.27300.00300
935–54150.00190.00340.00340
1055+139.09220.91360.00360
11Column sum411.82588.181,000.00
12Step 2: fit gender columnsMenWomenRow sumAge target
1318–34146.03153.71299.74300
1435–54178.48164.74343.22340
1555+165.50191.55357.04360
16Column sum490.00510.001,000.00
17Step 3: fit age rowsMenWomenRow sumAge target
1818–34146.16153.84300.00300
1935–54176.80163.20340.00340
2055+166.87193.13360.00360
21Column sum489.82510.181,000.00
22Raked weight (step 3 ÷ start)MenWomen
2318–341.6241.183
2435–541.1790.859
2555+0.9820.715
26Largest gap to the gender target0.18
27Max ÷ min weight2.27x
Key formulas
  • B8=B2*$E2/$D2Fit rows: cell × age target ÷ row sum
  • B13=B8*B$6/B$11Fit columns: cell × gender target ÷ column sum
  • B18=B13*$E2/$D13Fit rows again
  • B23=B18/B2Raked weight of young men
  • B26=MAX(ABS(B21-B6),ABS(C21-C6))Largest gap after step 3

Synthetic data for practice. Real surveys rake on the respondent file with more variables and a convergence tolerance.

From raked counts to respondent weights

The weight of every respondent in a cell is the raked count ÷ the original count: =B18/B2. Young men get 1.624 (each counts for 1.6 respondents), older women 0.715. The weights still add up to 1,000, so the weighted sample size is unchanged.

On a respondent file you do the same with SUMIF instead of a table: for each variable, compute the weighted total per category with SUMIF on the current weights, then multiply each respondent's weight by target ÷ weighted total for their category, and repeat. Survey software runs exactly this loop.

Check the weights: spread, trimming and the design effect

Weights cost precision. The ratio of the largest to the smallest weight is 2.27 here, which is mild. Kish's design effect, n × Σw² ÷ (Σw)², is about 1.07, so the 1,000 weighted interviews carry about as much information as 935 unweighted ones. When a few cells get very large weights, analysts trim them to a cap and rake again. Report the margin of error with the design effect, see margin of error in Excel.

Common mistakes

  • Multiplying all adjustment factors at once. Raking fits one margin at a time and uses the result of the previous step. One combined factor does not hit any margin exactly.
  • Targets that do not add up to the same total. Every margin must sum to the sample size (or the population), otherwise IPF cannot converge.
  • Stopping after one pass. After the last margin is fitted the earlier ones are off again. Repeat until the largest gap is below a tolerance.
  • Empty or tiny cells. A cell with no respondents can never be weighted up, and a cell with very few respondents gets extreme weights. Collapse categories first.
  • Never checking the spread of the weights. Look at the max ÷ min ratio and trim extreme weights before you publish estimates.
  • Reporting the unweighted margin of error. Weighting raises the variance. Use the design effect or the effective sample size.

Frequently asked questions

What is raking in survey weighting?

Raking is a weighting method that adjusts the weights so that the weighted sample matches known population totals on several variables, such as age, gender and region. It fits one variable at a time and repeats until all of them match.

What is the difference between raking and post-stratification?

Post-stratification needs the population count of every combined cell, for example men aged 18–34 in each region. Raking only needs the separate margins of each variable and finds weights that match all of them.

How many iterations does raking need?

Usually only a few when no cell is empty. In the example one row fit, one column fit and another row fit leave a gap of 0.18 in 1,000. Software stops when the largest change falls below a tolerance such as 0.001.

Does raking change the sample size?

The weights add up to the same total, so the weighted sample size stays at 1,000. The effective sample size falls, because unequal weights add variance, here to about 935.

Practise it in a lab

Related guides

Reading is step one. Doing is step two.

Every guide links to a lab where you build the same calculation in an online spreadsheet and get instant feedback.

Open the lab