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

Having conditional count on columns

Hi Experts,

I have a scenario as below.

There are orders in the system which will be at a STAGE for 'n' number of days.And for each stage there will be 'M' days given as SLA.

Now I would like to have a column  which gives me count of orders which have crossed the SLA.

ie, against each stage, I want the count of orders which has n>M.

Can some body pleeeease help me.

Many thanks in advance.

Lavanya

1 Solution

Accepted Solutions
Not applicable
Author

Hi Lavanya,

glad to help you.

To answer your second quest: Yes you can, but take care of the brackets:

count( if ( n>m and n<p), pag_id) 

---> should be: count( if ( n>m and n<p, pag_id))

This means that the if() delivers only those pag_ids to the count() which passed its filter.

RR

View solution in original post

8 Replies
Not applicable
Author

Hi Lavanya,

here a first guess for your chart-expression:

count( if(STAGE > SLA, order))

Regards, Roland

Not applicable
Author

Thanks very much Roland.

Is it count(if(n>M, order)) ?

Because, STAGE is a stage at which Order is at.

I have tried it like this,

Dimension as STAGE_CODE and

Expression as count(if(n>M, order)) but it dint fetch me any result.

Thanks for your help once again.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Try this.

   Create a straight table.

   Add dimension as Stage.

   Add expression as count({<N = {">M"}>}Order)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi again,

this should work when 'n' and 'M' are fields belonging to the same table as 'STAGE_CODE' and 'order'. Or they are in a table with a link to the "order-table".

I am quite sure you (we)  are not far away from the solution, but to find the last missing part it would be very helpfull if you post a little exam app. This can explain more then any description.

RR

Not applicable
Author

Thanks Roland.

You are right. I got it as below.

count(if(NUMBEROFDAYS >=SLA, PAG_ID)).

Thanks Koushik, I am there with Roland's suggestion.

Now since I have got it, is it possible for me into include some range in 'IF' condition.

like  count( if ( n>m and n<p), pag_id) ?

I know I am just missing with small bit of logic..

Many thanks for your time and help.

Regards

Lavanya

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Yes you can do that.

     If you want to achieve with set analysis. you will use below code.

    count({<N = {">M<P"}>}Order)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Lavanya,

glad to help you.

To answer your second quest: Yes you can, but take care of the brackets:

count( if ( n>m and n<p), pag_id) 

---> should be: count( if ( n>m and n<p, pag_id))

This means that the if() delivers only those pag_ids to the count() which passed its filter.

RR

Not applicable
Author

Many thanks for your help Roland

Regards