Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

qlikdash
Valued Contributor

how to equate 2 fields in SET ANALYSIS?

I have an if function: count(distinct if( [Product Code] = [UPC Code],ProductID)). how do I count ProductID using set analysis.

Thanks,

Tags (2)
7 Replies
MVP & Luminary
MVP & Luminary

Re: how to equate 2 fields in SET ANALYSIS?

You have a few options, but before that - keep in mind that Product should not be one of your Chart Dimensions. Set Analysis can not be sensitive to chart dimensions, because the selection is calculated once, before the chart is calculated.

With that in mind, here are a couple of different options:

Select [Product Code] based on the selected values of [UPC Code]:

count( {<[Product Code] = [UPC Code]>}  distinct ProductID)


Select [Product Code] based on the possible values of [UPC Code]:

count( {<[Product Code] = P( [UPC Code] )>}  distinct ProductID)


The difference between the two is very subtle and often non-existent, so pick your preferred syntax.


cheers,

Oleg Troyansky

QlikView Your Business: An expert guide to Business Discovery with QlikView and Qlik Sense

qlikdash
Valued Contributor

Re: how to equate 2 fields in SET ANALYSIS?

Thanks Oleg,

My real scenario is a little different. I have some more conditions:- count( {< [Field A]={'Active'}, [Field B]= {'Red','White','Blue'}, [Field C]={'On Demand'}, [Product Code] = [UPC Code]>}  distinct ProductID)

the first 3 condition is about the field value but the last one, which is my main concern is about equating 2 fields

not field values. It was a little strange, I followed what u said, and although there was a red line, it brought me the calculations at first and now it is not returning any lines/values. I was thinking more like defining the fields to be equated

with a variable if set analysis is to be used.

the above expn works fine with IF condition but not as good performance wise. Can you suggest with example of a variable in set analysis format. and how about if the condition is not equal to instead of equal to??

Thanks.

MVP & Luminary
MVP & Luminary

Re: how to equate 2 fields in SET ANALYSIS?

Your explanation is a bit confusing... I'm not sure that I understand your problem. If you could create a simple example and illustrate what's not working, I could possibly suggest a better solution.

neetha_p
Honored Contributor

Re: how to equate 2 fields in SET ANALYSIS?

hi,

Try:

Count( {< [Field A]={'Active'}, [Field B]= {'Red','White','Blue'}, [Field C]={'On Demand'}, [Product Code] = {'=[Product Code] = [UPC Code]'}>}  distinct ProductID)

MVP & Luminary
MVP & Luminary

Re: how to equate 2 fields in SET ANALYSIS?

Comparing fields in a set analysis expression can lead to unexpected results. I think you need to take a look at this qlikview document: set_analysis_intra-record.qvw


talk is cheap, supply exceeds demand
jose_vargas
Contributor

Re: how to equate 2 fields in SET ANALYSIS?

Hi. I tried something like you post, but Im no getting result. Y Try to do this.

if(Match([Razón Correción],'Discrepancia DAC') and (Categoria_Key=Categoria_Clasificada_Key or (Categoria_Key<>Categoria_Clasificada_Key and Categoria_Key <> Categoria_Detectada_Key)) ,  sum(Cantidad_Anomalia))

I want to do this with set analysis.but i dont have result.

sum({<[Razón Correción] = {'Discrepancia DAC'},[Categoria_Key]= {'=[Categoria_Key] =[Categoria_Clasificada_Key]'} >}[Cantidad_Anomalia])

Do you have any idea?

Highlighted
alan_richmond
Contributor

Re: how to equate 2 fields in SET ANALYSIS?

Hi Oleg

I purchased a copy of your book, love the book,  but cant find the supplemental data files on the publishers site, are you able to send me a copy of the data files please?

Regards,

Alan