Mitchel Roling
04/15/2022, 1:35 AMMitchel Roling
04/15/2022, 12:17 PMMitchel Roling
04/15/2022, 1:51 PMMichal Hauzírek
04/15/2022, 4:06 PMSELECT COUNT(*person*) BY ALL *response*
the “BY ALL response” here means “do not split the result by response even if the report is split by it and for each value display the total number of responses”.
If you also want this number to show the total even if you filter out a specific response (i.e. if you filter for “Yes” and want to include also “No” and “Maybe” in the total number) you would use this metric:
SELECT COUNT(*person*) BY ALL *response* WITH PF EXCEPT *response*
the WITH PF EXCEPT means - apply all the filters but ignore filter for response.
So to calculate % of total responses, you can do it like this:
SELECT COUNT(*person*)/(SELECT COUNT(*person*) BY ALL *response* WITH PF EXCEPT *response*)
Mitchel Roling
04/15/2022, 4:59 PMMitchel Roling
04/15/2022, 4:59 PMMitchel Roling
04/15/2022, 4:59 PMMitchel Roling
04/15/2022, 5:02 PMMitchel Roling
04/15/2022, 5:02 PMMichal Hauzírek
04/15/2022, 5:28 PMMitchel Roling
04/15/2022, 5:51 PMMitchel Roling
04/15/2022, 5:51 PMMichal Hauzírek
04/15/2022, 5:59 PMSELECT SUM(weight) BY ALL *response* WITH PF EXCEPT *response*
Mitchel Roling
04/15/2022, 6:57 PMMitchel Roling
04/15/2022, 6:57 PMMichal Hauzírek
04/15/2022, 6:58 PMMitchel Roling
04/15/2022, 7:00 PMMitchel Roling
04/15/2022, 7:00 PMMitchel Roling
04/15/2022, 7:01 PMMitchel Roling
04/15/2022, 7:01 PMMitchel Roling
04/15/2022, 7:02 PMMitchel Roling
04/15/2022, 7:03 PMMitchel Roling
04/15/2022, 7:03 PMMitchel Roling
04/15/2022, 7:19 PMMichal Hauzírek
04/15/2022, 9:23 PMSELECT SUM(*Weight*) / (SELECT SUM(*Weight*) BY *Question*,*Country* WITH PF EXCEPT *Answer*)
In your sample data the Question and Country are aligned, I am not sure if it would be the case also in more general case, but for this example this metric seems to do exactly what you need and is dynamic based on what you filter.Jakub Sterba
04/15/2022, 10:28 PMJakub Sterba
04/15/2022, 10:49 PMSELECT MAX(SELECT SUM(Weight) / (SELECT SUM(Weight) BY ALL Answer WITH PF EXCEPT Answer BY Question)
And for example view such metric by Question as rows and Answer as columns.
Or you can use filter Question in (‘Do you live in US’, ‘Do you live in France’) and filter Answer=‘Yes’ and view it by ‘Country’. In case you select by mistake multiple questions with the same country, it will show the highest percentage of a question for given country.Mitchel Roling
04/16/2022, 12:18 PMMitchel Roling
04/16/2022, 10:18 PMJakub Sterba
04/17/2022, 7:16 AMSELECT SUM(SELECT Weight BY Records of Responses)
lets you lift fact from the dataset Respondents to dataset Responses supposing you have connected them in the model (arrow points from Respondents to Responses where RespondentId is used as foreign key to Respondent dataset and there is none primary key set in the dataset Responses). If you have a primary key defined in Responses dataset such as Response Id you have to use it instead of Records of Responses which is automatically created attribute only in case primary key does not exist ( SELECT SUM(SELECT Weight BY Response Id)
), Such statement will not sum weight of each respondent but it will repeat weight in each response of that person and then sum up all the responses. The total may be higher than sum of weights of all resondents. You can use such metric instead of SUM(Weight) in the metric with BY rules which calculates the percentage.Mitchel Roling
04/18/2022, 11:39 AM