Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
rds694
Contributor
Contributor

Percentages by flexible group

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.

ryandsimpson94_7-1651677439357.png

 

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:

ryandsimpson94_2-1651677144369.png

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.

ryandsimpson94_4-1651677280396.png

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.

ryandsimpson94_6-1651677378850.png

Any thoughts on these issues I'm having? I just don't understand what I'm doing wrong!

 

Labels (5)
12 Replies
gp_oconnor
Partner - Contributor III
Partner - Contributor III

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.

rds694
Contributor
Contributor
Author

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?

vinieme12
Champion III
Champion III

As below

 

sum(Response) / sum(total <$(=GetObjectField(0))> Response)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rds694
Contributor
Contributor
Author

I'm getting an error with that syntax

rds694_0-1651688334094.png

 

vinieme12
Champion III
Champion III

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)))

 

qlikCommunity1.PNG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rds694
Contributor
Contributor
Author

It's not working at all. Now no results are showing.

rds694_0-1651689656778.png

rds694_1-1651689693148.png

 

 

vinieme12
Champion III
Champion III

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)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
gp_oconnor
Partner - Contributor III
Partner - Contributor III

That is a data modelling issue rather than a front end / expression issue.  Use crosstable in the load script to transform the data.

rds694
Contributor
Contributor
Author

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?