Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
maxsheva
Creator II
Creator II

Set Analysis. Field is not equal other field.

Hi,

How can I replace expression below with set analysis?

if(Field1=Field2, 0, Sum(Value))

I tried different variants. For example this one doesn't work as well.

Sum({$<Field1-=Field2>} Value)

1 Solution

Accepted Solutions
ahaahaaha
Partner - Master
Partner - Master

May be


Sum({<Field2={"=Field1<>Field2"}>}Value)



1.jpg

View solution in original post

10 Replies
Anil_Babu_Samineni

Better to use in script like

If(Field1 <> Field2 , 1, 0) as Flag

And set analysis

Sum({<Flag = {'1'}>}Value)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ahaahaaha
Partner - Master
Partner - Master

Try

=Sum({<Field1={"=Field1<>Field2"}>}Value)

antoniotiman
Master III
Master III

Hi Max,

Set Analysis is calculated per Chart  and You need per Rows.

So

Sum(If(Field1=Field2,0,Value))

However Sintax Set Analysis is like this

Sum({<Field1-={'$(=Max(Field2))'}>} Value)

or like this

Sum({<Field1=E(Field2)>} Value)

Regards,

Antonio

maxsheva
Creator II
Creator II
Author

Thanks but all versions of set analysis don't show an expected result.

I can't use flag in script according to current data model.


Please look at the attachment qvw

First chart shows correct result with IF statement.


Other ones with all set analysis variants above. They show different.

antoniotiman
Master III
Master III

In this case the Expression must be evaluated per row, then You need If() instead of Set Analysis.

ahaahaaha
Partner - Master
Partner - Master

May be


Sum({<Field2={"=Field1<>Field2"}>}Value)



1.jpg

avinashelite

If its a row to row comparison then I would prefer to have it in the script level .....in the front end it will take lot of time to evaluate and render 

maxsheva
Creator II
Creator II
Author

Thanks all and especially Andrey.

to avinashelite

I have created matrix where all values in field1 are equals to all values in field2. Let's say field2 is duplicate from field1.

How can I create flag in script in this case?

avinashelite

if you share the sample data set we could help you out..create a separate thread