First of all, thanks for taking the time to think this through and provide a solution, which mimics the spreadsheet approach used in excel. It is very elegant and easy to follow.

So let me complicate this further. Many data sources have respondent level information with segment and classifications across a variety of classifications including demographic profiles, clusters, and factor groupings. The solution approach provided suggests that a pre-processing step is needed to develop individual a contingency tables and then use that data as input to obtain the desired views of the data. Scaling this approach, any filtering at the respondent level would need require pre-processing to be repeated in the workflow.

So is there a method to create the final output directly from the original data source without a pre-processing step?