Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

shumailh
Contributor III

Set Analysis Issue - Comparing two Fields

I am trying to compare two fields and unable to get the required value, below is my data:

AccNoMonthName_IDMonthNameMTD_IDMonthNameyTD_IDMonthNameYOY_IDBal
12456Jan-11Dec-10Jan-11Feb-10   154,100.00
15144May-11Apr-11Jan-11Jun-10     10,054.00
65112Jun-11May-11Jan-11Jul-10   320,496.00
41120Nov-10Sep-10Jan-10Dec-09     12,054.00
45661Apr-11Mar-11Jan-11May-10     21,560.00
57482Jun-11May-11Jan-11Jul-10       1,541.00
78441May-11Apr-11Jan-11May-10   540,000.00

Below is the expression i am using to get the bal

=(sum({$<MonthName_ID = ${MonthNameMTD_ID}>} bal)

Shumail

8 Replies
erich_shiino
Honored Contributor

Set Analysis Issue - Comparing two Fields

Try this:

=(sum({$<MonthName_ID ={"=$(MonthNameMTD_ID)"}>} bal)

Hope this helps,

Erich

shumailh
Contributor III

Set Analysis Issue - Comparing two Fields

not working i tried the same after correction but still no solution

=sum({$<MonthName_ID ={"=$(MonthNameMTD_ID)"}>} bal)

I review the below link which mentions that i could nt compare two fields in set analysis... [Smiley Frustrated]

http://community.qlik.com/message/101556#101556

Highlighted
erich_shiino
Honored Contributor

Re: Set Analysis Issue - Comparing two Fields

Hi,

I changed the syntax a little bit

Please, check attachment

Regards,

Erich

vikasgupta
Contributor

Re: Set Analysis Issue - Comparing two Fields

Hi Erich

I wants to compare two fields using set expression. I used your expression but i am not getting required result its return 1000 instead of 700 so i wants to ask you that we can not use set expression for comparing two fields ?

but if we are using IF condition then its working correct.

plz finds the attached for same and if if any alternative is there then plz let me know .

Thanks

Vikas gupta

Not applicable

Re: Set Analysis Issue - Comparing two Fields

Thanks!!! I was searching for this solution!

MVP
MVP

Re: Set Analysis Issue - Comparing two Fields

=sum( {$ <AccNo={"=MonthName_ID=MonthNameyTD_ID"}>} Bal )

Not applicable

Re: Set Analysis Issue - Comparing two Fields

I don't understand why "1000" is returned. We're comparing fields (Table1.Name and Table2.Name) from separate tables which have no join (i.e. joinless tables -- no line between them in the editor) Since there is no join, maybe the comparison is moot. (Qlikview just does the cartesian product when you mix joinless tables) And since you're summing Table2.Amt, it just checks whether Table2 is filtered at all and accepts that filter...

rcurlewis
New Contributor II

Re: Set Analysis Issue - Comparing two Fields

Hi Shumail,

My suggestion is to look at the P/E options in SET ANALYSIS.  It works when you want to say P = Possible Values a E = Exclude Values.

I use it as follows as an example: Sum({<[Type]= {'Value'}, [Field1]= P(Field2)>} [Amount]).  Note the Round Brackets with P/E as these are functions.

Your expression: =(sum({$<MonthName_ID = P(MonthNameMTD_ID)>} bal)

Hope this helps

*Sorry just a note.  This is taking every Possible Value and not just the value - so test it as this resolved quite a number of my issues in the past*

According to Rob Wunderlich you can also do this: sum({<RecId={"=F1=F2"}>}Amount)

Community Browser