Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

aniruddhyadutta
New Contributor

Coverting a condtion to set analysis

Can some help me convert this as set analysis:

I have some unique P_ids against which I am checking the below condition to  differntiate which are error and no error

=if ( not IsNull(C_ID) and not match(P_STATUS,'success') and  match(P_NAME,'SPL') and aggr(count(if (match(P_STATUS,'errors'),1)),C_ID)=1,'error','no_error')

I just want to get total number of 'error' or 'no_error'

so I am expecting some thing like

Count({$<condtion1,condition 2,condition 3>}  P_ids) -->total count for errors

similar one for no_error.

Tags (1)
4 Replies
omarbensalem
Esteemed Contributor

Re: Coverting a condtion to set analysis

what happens when you use your expression?

I mean the =if ( not IsNull(C_ID) and not match(P_STATUS,'success') and  match(P_NAME,'SPL') and aggr(count(if (match(P_STATUS,'errors'),1)),C_ID)=1,'error','no_error')

?

MVP
MVP

Re: Coverting a condtion to set analysis

May be this

For count of errors:

=Sum(if( not IsNull(C_ID) and not match(P_STATUS,'success') and  match(P_NAME,'SPL') and aggr(count(if (match(P_STATUS,'errors'),1)), C_ID) = 1,1, 0)

For count of no errors:

=Sum(if( not IsNull(C_ID) and not match(P_STATUS,'success') and  match(P_NAME,'SPL') and aggr(count(if (match(P_STATUS,'errors'),1)), C_ID) = 1, 0, 1)

aniruddhyadutta
New Contributor

Re: Coverting a condtion to set analysis

As you see I have aggr function so I am not able to use in the back end to flag my data set rows.So I am left with the option of aggregating in the front end

omarbensalem
Esteemed Contributor

Re: Coverting a condtion to set analysis

I meant that Qlik permits you to work with if conditions like you have been doing; if you expression works fine with if conditions, you can always use it without transforming it into a set analysis' shape; sthink like

sum(

if( not IsNull(C_ID) and not match(P_STATUS,'success') and  match(P_NAME,'SPL') and aggr(count(if (match(P_STATUS,'errors'),1)), C_ID) = 1,1, 0)

)