Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count the records based on column value

Hi,

As i'm new to qlikview, i would want to know how to achieve the below scenario in QlikView.

I have a file with 5 columns namely ID, Name, Gender, Year and Promotion, See the attached file

Now in the chart i need to display the count of ID's both Genderwise and Promotionwise per year. Please note that Gender has two values M and F while Promotion has Y and N respectively. To be precise i need to get the count of both male and female ID's for each year, at the same time i need to get the count of the ID's who have got promotion.

I used the below code in the CHART expression :

=count(distinct if( Gender='M', ID) ) >>>>>  for Gender

=count(distinct if( Promotion='Y' , ID) )  >>>> for Promotion

I have used the COMBO chart for the same, where Gender is represented in Bar while Promotion Count in Line. But the problem is that, I'm getting the total count(both male and female) for each year instead of the data appearing to be in a stacked format. ( See the snapshot below)

For Eg: If I have 5 records for the year 2010 out of which 3 are M(Male) while the rest are F. In this case while representing in chart, i need to get the data in a stacked format which differentiates the count between male and female for each year respectively.

Can you please assist  me ?

Regards,

surman

9 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file, hope it helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

As i'm using a personal edition, i'm not able to open the document sent by you.

whiteline
Master II
Master II

To make a  stacked bar on combo chart you have to use two expressions for bars:

=count(distinct if( Gender='M', ID) )

=count(distinct if( Gender='F', ID) )

For Promotion you should check two conditions:

=count(distinct if( Promotion='Y' and Gender='M' , ID) )

=count(distinct if( Promotion='Y' and Gender='F' , ID) )

Not applicable
Author

Hi,

I dint understand how to use two expressions for BAR and LINE charts seperately ?

Can you please let me know how to do this ?

Not applicable
Author

Hi,

I dint understand how to use two expressions for BAR and LINE charts seperately ?

Can you please let me know how to do this ?

Regards,

surman

Not applicable
Author

Hi,

I dint understand how to use two expressions on BAR  and Line Charts seperately ? Can you please let me know how to do it ?

Regards,

surman

Not applicable
Author

Hi,

I dint understand how to use two expressions on BAR  and Line Charts seperately ? Can you please let me know how to do it ?

Regards,

surman

Not applicable
Author

Hi,

I dint understand how to use two expressions on BAR  and Line Charts seperately ? Can you please let me know how to do it ?

Regards,

surman

whiteline
Master II
Master II

Create 4 expressions as I've  mentioned above.

When you select expression you can toggle checkboxes 'Bar', 'Symbol','Line'.

Toggle appropriate for each expression.

Then select 'Stacked' style on presentation tab.