How it works...

For such a small amount of DAX code, the Cohort measure hides perhaps one of the trickiest DAX computations ever devised, a computation that would likely give even DAX masters a moment's pause to understand how the calculation works. This calculation is only possible because of the peculiar interaction between particular, individual features of three DAX functions: GENERATE, DISTINCT, and CALCULATETABLE. Exactly how this calculation operates and why it does will be explained shortly, but first, let's go over the overall measure calculation.

The first table variable we created, __Table, contains a list of patients and diagnosis codes for patients that do NOT have all of the diagnoses selected in the slicer. This table contains ...

Get DAX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.