Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis Ignore Field

Hi,

I have the following table:

StudentIdYearClassSectionGrade
1Current11AA
2Both10BA
3Previous2CA
4Both3AB
5Current4DB
6Both10DB
7Previous11DB
8Both10BB
9Current11AB
10Both2CA

I need a count of students who belong to current/both year or Previous/Both year, ignoring the selections in Section, Class and Grade.

I am currently using the following set analysis expression, but it is giving me wrong counts. vSelectedYear is user input has 2 possible values 'Current' or 'Previous'

=if (vSelectedYear = 'Current', Count(DISTINCT{1<[Year]={'Current', 'Both'}>} [StudentId]),

Count(DISTINCT{1<[Year]={'Previous', 'Both'}>} [StudentId]))

Kindly Suggest!

Labels (1)
9 Replies
petter
Partner - Champion III
Partner - Champion III

If you're expression is exactly like you show above it is missing an ) and have a , extra....

=if (vSelectedYear = 'Current', Count(DISTINCT{1<[Year]={'Current', 'Both'}>} [StudentId]),

Count(DISTINCT{1<[Year]={'Previous', 'Both'}>} [StudentId])  )


This is a complete expression that is error free syntactically but not necessarily logically ....

Not applicable
Author

The extra ) is not extra, but closing bracket of if condition.

petter
Partner - Champion III
Partner - Champion III

With this simplified expression you should get the filter you want:

Count({1<[Year]={'$(vSelectedYear)', 'Both'}>} [StudentId])

Not applicable
Author

Returns the same counts that my original expression returns.

sunny_talwar
MVP
MVP

What is the expected output here? Seems to be working

Current -> 8

Previous -> 7

What is the issue?

Not applicable
Author

Well, on the real and bigger dataset this expression is giving wrong counts.

sunny_talwar
MVP
MVP

If its working in the sample, it would be difficult to know why it isn't working on the real application without taking a look at it. Can you introduce the same problem in your sample? May be these links can help

Preparing examples for Upload - Reduction and Data Scrambling

Uploading a Sample

petter
Partner - Champion III
Partner - Champion III

Yes after you edited your question .... 😉

Not applicable
Author

Haha!! Only the extra comma was removed, but the extra ) was not removed from the original post.