Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I'm trying to make a visualization with flexible groupings to analyze survey data, in which the percentages are counted as a portion of the first grouping, not of the overall total. So this is what I'm looking for.
I plan to use variables with user selected parameters to get the groups, but first I wanted to get it to work with fixed dimensions. I've gotten it to work for a single grouping, but flexible grouping is causing me issues. To get the above image I used the following expression:
=Count(GetObjectDimension(1))/Count(Total <[To which of the following age groups do you belong?]> getObjectDimension(1)
Ideally, I'd replace the hard coded <[To which of the following age groups do you belong?]> with something along the lines of <getObjectDimension(0)> but I can't figure out the syntax to make that work.
Also, I've tried using if statements to determine the field grouped on in Group 1, but that seems to mess up the percent by grouping. In the image above (which calculated what I wanted), my Group 1 dimension expression was hard coded as the age group field:
However the moment I add an if statement into the equation in messes up the calculations. For instance, even this following statement, which should return the exact same field causes an issue.
After making this simple change to the Group 1 dimension (which really shouldn't change the results at all), the percentages are no longer at 100% per group, but instead out of every group combined.
Any thoughts on these issues I'm having? I just don't understand what I'm doing wrong!
I think the attached app (utilizing some basic test data) provides a solution. I don't know why the options you have tried aren't giving you the desired results.
I notice you have a "Question" and "Response" column. However, I have a separate column for every single Question, with a response for each survey answer. How would I adjust the measure expression to work for that situation?
As below
sum(Response) / sum(total <$(=GetObjectField(0))> Response)
I'm getting an error with that syntax
That is because you haven't used it exactly the way I've posted, it needs to be placed within $(=)
it will evaluate to '-' and show error in expression but you will get the desired result
just copy paste the below
count($(=GetObjectDimension(0))) / count(TOTAL $(=GetObjectDimension(0)))
It's not working at all. Now no results are showing.
mate, i'm just showing you an example of how to use getobjectdimension()
I don't know how you are actually using it in the chart
What field do you exactly want to count on ?
You haven't posted any sample data or information about how your data is structed so i can only assume
count(Response) / count( <$(=getobjectdimension(0))> Response)
That is a data modelling issue rather than a front end / expression issue. Use crosstable in the load script to transform the data.
The crosstable suggestion helped a lot in terms of managing a lot of different options for dimensions. However, I'm a bit confused with the file you sent me. In it, you have the following code:
Count({<[Question]={'$(vQuestion)'}>} [ResponseID])
/
Count({<[Question]={'$(vQuestion)'}>} Total <[Question],[vSurveyDimension]> [ResponseID])
However, I don't quite understand how the variables fit in here and I can't get it to show the percentages by group as I would want. Any thoughts on what I'm missing?