
上QQ阅读APP看书,第一时间看更新
Goodness-of-Fit logic and syntax
- The logic implemented by the Goodness-of-Fit statistic measure can be described by the following table:

Goodness-of-Fit Statistic Sample Data Logic
- The expected variables all reference and re-use the SampleCount variable, which is filtered for 2017-Q1.
- A SUMX() function is used to used to iterate over each of the six countries represented by a single row via VALUES()
- This distinct list of countries is filtered to avoid any NA values
- The Sample Customer Count measure created in step 1 executes in a filter context to provide the observed customer count for the given country
- The observed and expected values are passed into the Goodness-of-Fit equation with the sum of each calculation (one for each country) being returned by the measure
Observe that the SampleCount variable is re-used by the expected variables but that the Sample Customer Count measure created in step 1 is used within the SWITCH(). This is because the measure executes in a filter context (the given country) whereas the SampleCount variable does not transition to a filter context when invoked in the expression.