The Punjab census asked people their religion from 1881 and required a single answer.
That was harder than it sounds. Large numbers of people followed Sakhi Sarwar and also went to a gurdwara; kept a jathera and a pir's grave; described themselves by caste rather than religion; or gave answers the enumerators could not classify. Early census reports discuss the problem at length and then produce clean tables anyway.
The reform movements then used those tables. A community's share of the population determined its claim to representation, employment and eventually territory, so every movement had an interest in maximising its own count, and the census became a contest.
By 1941 the province was understood by everyone, including by the people in it, as three communities with fixed proportions.
In 1947 those proportions were used to divide it.
The line from a question on a form in 1881 to a boundary on a map in 1947 is not direct and it is not accidental either, and it is one of the most consequential things the colonial state did in Punjab.
The decennial census counted people by religion, caste and tribe, and published the tables by district, which made the province's communities into countable and comparable blocks.
Those tables became political facts. Representation, recruitment quotas, land rights and later the partition of the province were all argued using census categories.
The reform movements responded to the counting. Campaigns to have people record themselves as Sikh, Hindu or Muslim in a particular way were run before several censuses, and the numbers moved.