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: 
Anonymous
Not applicable

What would be the best way to calculate Total count of a specific value across multiple fields

PersonDayRating 1Rating 2Rating 3Rating 4Rating 5
Person ADay 1ExcellentSatisfactorySatisfactorySatisfactorySatisfactory
Person ADay 2SatisfactorySatisfactoryExcellentUnsatisfactorySatisfactory
Person ADay 3SatisfactorySatisfactorySatisfactoryUnsatisfactorySatisfactory
Person BDay 1SatisfactorySatisfactoryExcellentExcellentUnsatisfactory
Person BDay 2UnsatisfactoryUnsatisfactorySatisfactoryExcellentSatisfactory
Person BDay 3SatisfactoryUnsatisfactoryUnsatisfactorySatisfactorySatisfactory

This is my data.  I want to count the number of Excellent, Satisfactory and Unsatisfactory values across all days for each person.  So, I would end up with:

PersonExcellentSatisfactoryUnsatisfactory
Person A2112
Person B375

And, of course, I would love to be able to drill down on the chart to find out which ratings had 2 Excellent for Person A, etc.

What is the best way to calculate and display this information?

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps with these expressions:

rangesum(count({<[Rating 1]={'Excellent'}>}[Rating 1]),count({<[Rating 2]={'Excellent'}>}[Rating 2]),count({<[Rating 3]=

{'Excellent'}>}[Rating 3]),count({<[Rating 4]={'Excellent'}>}[Rating 4]),count({<[Rating 5]={'Excellent'}>}[Rating 15))


rangesum(count({<[Rating 1]={'Satisfactory'}>}[Rating 1]),count({<[Rating 2]={'Satisfactory'}>}[Rating 2]),count({<[Rating 3]={'Satisfactory'}>}[Rating 3]),count({<[Rating 4]={'Satisfactory'}>}[Rating 4]),count({<[Rating 5]={'Satisfactory'}>}[Rating 15))


rangesum(count({<[Rating 1]={'Unsatisfactory'}>}[Rating 1]),count({<[Rating 2]={'Unsatisfactory'}>}[Rating 2]),count({<[Rating 3]={'Unsatisfactory'}>}[Rating 3]),count({<[Rating 4]={'Unsatisfactory'}>}[Rating 4]),count({<[Rating 5]={'Unsatisfactory'}>}[Rating 15))


talk is cheap, supply exceeds demand
maxgro
MVP
MVP

sum(aggr(SubStringCount(

          Left([Rating 1],1)&Left([Rating 2],1)&Left([Rating 3],1)&Left([Rating 4],1)&Left([Rating 5],1),

          'U'          /* or E or S  for other expressions */

     ), Person, Day)

)

1.png

swuehl
MVP
MVP

Or transform your data using CROSSTABLE LOAD prefix

The Crosstable Load

CROSSTABLE( RatingNo, Rating,2)

LOAD Person,

    Day,

    [Rating 1],

    [Rating 2],

    [Rating 3],

    [Rating 4],

    [Rating 5]

FROM

[https://community.qlik.com/thread/248507]

(html, codepage is 1252, embedded labels, table is @1);

Which makes dimensions / expression trivial and allows to drill in

2017-02-02 21_53_56-QlikView x64 - [C__Users_Stefan_Downloads_comm248507.qvw].png

2017-02-02 21_54_18-QlikView x64 - [C__Users_Stefan_Downloads_comm248507.qvw].png