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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mattphillip
Creator II
Creator II

User defined field within expression

Hoping someone can help. I have an expression for calculating percentages within a table where users can define the visible fields:

=count({$<[Retained]={'Yes'}>}[Student ID])/count(TOTAL <GetFieldSelections(Fields)> [Student ID])

The getfieldselections statement is meant to allow users to specify what the context of the calculated percentage e.g. by programme, gender, session etc. However when I try this, the calculation is blank.

Does anyone know where I might be going wrong?

Appreciated.

Matt

1 Solution

Accepted Solutions
sunny_talwar

May be try this

=Count({$<[Retained]={'Yes'}>}[Student ID])/Count(TOTAL <$(='[' & GetFieldSelections(Fields, '], [') & ']')> [Student ID])

View solution in original post

7 Replies
sunny_talwar

May be try this

=Count({$<[Retained]={'Yes'}>}[Student ID])/Count(TOTAL <$(='[' & GetFieldSelections(Fields) & ']')> [Student ID])

mattphillip
Creator II
Creator II
Author

Thanks Sunny that does work! One question though, is there a way for it to accept multiple selections? E.g. selecting session and gender to display a percentage which adds up to 100% for each session.

Thanks,

sunny_talwar

May be try this

=Count({$<[Retained]={'Yes'}>}[Student ID])/Count(TOTAL <$(='[' & GetFieldSelections(Fields, '], [') & ']')> [Student ID])

mattphillip
Creator II
Creator II
Author

Brilliant thanks!

mattphillip
Creator II
Creator II
Author

Hi Sunny,

Hoping you might be able to help with a quick question, I'm trying to add in an additional set analysis criteria (specifying a particular session) to the above expression but it's throwing up errors. Any ideas why?

=count({$<[Retained]={'Yes'},[Session]={'2015/16'}>}[Student ID])/count(TOTAL <{$(='[' & GetFieldSelections(Fields, '], [') & ']'),[Session]={'2015/16'}>}[Student ID])

Many thanks,

Matt

sunny_talwar

Because what I added was not set analysis, it was field name used by TOTAL qualifier... try this

=Count({$<[Retained]={'Yes'}, [Session]={'2015/16'}>} [Student ID])/Count({<[Session]={'2015/16'}>} TOTAL <$(='[' & GetFieldSelections(Fields, '], [') & ']')> [Student ID])

mattphillip
Creator II
Creator II
Author

Its been a long day...thanks Sunny, much appreciated!