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: 
QlikSenseBeginner
Contributor II
Contributor II

Count the outcome by comparing 3 column

Hi Qlik Community, 

Need your help with the Set Analysis.

The following is a sample excel data.  

 

 

INTERNSHIP COMPANY CLEANED TOP EMPLOYERS CLEANED Were you offered a position by the company you were attached to for your internship or work attachment
A A Yes. I am currently working in the company that I was attached to
  B Yes. I am currently working in the company that I was attached to
  C Yes. I am currently working in the company that I was attached to
  D Yes. I am currently working in the company that I was attached to
EE EE No. I was not offered a position and my internship(s) / work attachment(s) / work study scheme(s) did not help me obtain a job in other ways
FF F No. I was not offered a position, but the internship(s) / work attachment(s) / work study scheme(s) has helped me obtain a job in other ways
GGG GGG

Yes. I am currently working in the company that I was attached to

I would like to count the number of cases where column 1 = column 2 = column 3 'Yes. I am currently working in the company that I was attached to'.  Which i can tell from the table that the count should be 2.

What would be the set analysis that i should have? I have a slight idea what i wanted but i need some help. 

 

count({$<[INTERNSHIP COMPANY CLEANED]={[XXX]},TOP EMPLOYERS CLEANED={[XXX]},[OFFERED POSITION]={[Yes. I am currently working in the company that I was attached to]}>} [Were you offered a position by the company you were attached to for your internship or work attachment])

Matric is a unique ID. 

Can the XXX be left as wild card? 

Labels (1)
7 Replies
Kushal_Chawda

@QlikSenseBeginner  to use set analysis, you will need PrimaryKey in your table. If you don't have you can create it using RowNo() as use below set analysis

Data:
Load *,
         RowNo() as Row
FROM table;

 

 

Where Row is primary key of the table. If you already have it, you can utilise it.

=Count({<Row= {"=[INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED]"}, [OFFERED POSITION]={'YES'}>}Metrics)

If you don't have primary key and you don't want to create it using load script, you can use if condition expression as below

=count(if([INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED] and [OFFERED POSITION]='YES', Row))

 

QlikSenseBeginner
Contributor II
Contributor II
Author

This part seems interesting 

count(if([INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED] and [OFFERED POSITION]='YES', Row))

If i do not need the ROW is there another way to write this? 

Kushal_Chawda

@QlikSenseBeginner  Yes with if you don't need Row as it will perform row by row operation.

count(if([INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED] and [OFFERED POSITION]='YES', Merics))

 

QlikSenseBeginner
Contributor II
Contributor II
Author

Thanks, it says error. 

IF takes 2-3 parameters.  

count(if([INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED] and [OFFERED POSITION]='YES', Matric))

Kushal_Chawda

@QlikSenseBeginner  Id your Meric is other expression? you need to use the field which you want to count.

QlikSenseBeginner
Contributor II
Contributor II
Author

I have revised the table a little.  Hopefully it brings some light to the reader.  Only when the following met it will be counted as 1

INTERNSHIP COMPANY CLEANED TOP EMPLOYERS CLEANED Were you offered a position by the company you were attached to for your internship or work attachment
A A

Yes. I am currently working in the company that I was attached to

 

Kushal_Chawda

@QlikSenseBeginner  try below

count(if([INTERNSHIP COMPANY CLEANED]=[TOP EMPLOYERS CLEANED] and [OFFERED POSITION] like 'Yes*',[INTERNSHIP COMPANY CLEANED]))