Dim resPortfolio As Portfolio Dim ProfileRow as Profile ' Define a profile of row questions to add to Dim ProfileCol as Profile ' Define a profile of column questions to add to Dim resItem As PortfolioItem ' Set the wave response numbers for previous & current waves Dim numPrevWave = ^Wave^.Responses.Count-2 Dim numCurrWave = ^Wave^.Responses.Count-1 ' Create sub-pops for current and previous waves Dim spPrevWave As SubPopulation spPrevWave.Name = "Previous Wave" spPrevWave.Script = "Wave.Value Has " + numPrevWave.ToString() spPrevWave.Save() Dim spCurrWave As SubPopulation spCurrWave.Name = "Current Wave" spCurrWave.Script = "Wave.Value Has " + numCurrWave.ToString() spCurrWave.Save() Dim h For h = 1 to Survey.Questions.Count ' Iterate through every question of the survey Dim currQuestion = Survey.Questions[h] Dim arrResponses = {} Dim qFlag = False 'Define question types to include/exclude Dim nonChap = currQuestion.Type <> "chapter" Dim nonOpen = currQuestion.Type <> "open" Dim nonCod = currQuestion.IsCoding = False Dim isVis = currQuestion.IsVisibleDuringDataEntry = True ' Only for non-chapters, non-open, non-developed and visible questions If nonChap and nonOpen and isVis and nonCod Then Dim i For i = 1 to currQuestion.Responses.Count-1 ' Iterate through every response of the current question ' Define the elements of the col sig formula 'Classical Student Test' ' (https://support.askia.com/hc/en-us/articles/207122855-Programming-Col-Sig-proportions-Part-1-Classical-Student-Test-) Dim dN1 = currQuestion.Data.Filter(spPrevWave.Name).Counts(currQuestion.Responses.Index - currQuestion.Responses.Index.Max())[1] Dim dN2 = currQuestion.Data.Filter(spCurrWave.Name).Counts(currQuestion.Responses.Index - currQuestion.Responses.Index.Max())[1] Dim dP1 = currQuestion.Data.Filter(spPrevWave.Name).Counts({}.Push(i))[1] / dN1 Dim dP2 = currQuestion.Data.Filter(spCurrWave.Name).Counts({}.Push(i))[1] / dN2 Dim dA1 = dP1 * (1 - dP1) / dN1 Dim dA2 = dP2 * (1 - dP2) / dN2 Dim dDenom = (dA1 + dA2).Pow(0.5) Dim dSigma = (dp1 - dp2).Abs() / dDenom If dSigma > 1.96 Then ' Test at 95% (normal level) arrResponses = arrResponses + i ' Only select the row responses which have significant diff between current/previous wave qFlag = True ' Set the flag true to select the question later outside of the response loop Endif Next i Endif If qFlag = True Then ProfileRow.Add(currQuestion,arrResponses) ' Add the question to the row question profile with the only the responses which had significance Endif Next h ' Add Wave to columns with only previous & current waves selected Dim arrWaveCurrPrev = {}.Push(numPrevWave).Push(numCurrWave) ProfileCol.Add(^Wave^,arrWaveCurrPrev) resItem.SetType(1) resItem.SetTitle("Col Sig Selection (%) Holecount by Wave") resItem.TabDef.Title = "??R?? x ??C??" resItem.TabDef.ReadTabTemplate("Askia2a") resItem.TabDef.SetUniverse(-3) resItem.TabDef.ReadTabStyle("Regal") resItem.TabDef.Rows.add(ProfileRow) ' Add the profile to the rows of the tab definition resItem.TabDef.Columns.add(ProfileCol) ' Add the profile to the columns of the tab definition resPortfolio.Add(resItem) ' Add the tab definition to the portfolio resPortfolio.Save(Survey.Directory + "Col Sig (%) Selection Holecount by Wave") resPortfolio.Open()