Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannagr
Creator III
Creator III

difference between these set analyses

Hi all.

What is the difference If i do

count({< filter1={"=len(filter1)=2"}, id={"=count(distinct date)>=1">} distinct id)

and if do 

count({<  id={"=count(distinct date)>=1 and len(filter1)=2">} distinct id) ?

 

It has me a lot confused, because each of it applies to this distinct id each time. The numbers though are a lot different.

Can't waiti for your input! Thanks.

9 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @ioannagr ,

What is the logic behind that expressions?

What are you trying to achieve?

ioannagr
Creator III
Creator III
Author

What i want to find is the ids that have showed up more than once (count distinct date >=1) and that for them the length of this field "filter1" is 2. I used to do it using the first way which is in essence the intersection, but I was wondering why not do the second way? But they differ a lot, even though in the end with my initial count set analysis i want to refer to the id. @agigliotti 

agigliotti
Partner - Champion
Partner - Champion

if a logic AND is needed between the two conditions , I'd use the below expression:

=count( {< id = {"=count(distinct date)>=1 and len(filter1)=2"} >} distinct id )

I hope it can help.

Best Regards

ioannagr
Creator III
Creator III
Author

@agigliotti what is the other logic for then? How are they different?

agigliotti
Partner - Champion
Partner - Champion

the two expressions should return the same value because they are doing the same calculation.

there was a missing bracket in the below expression:

count({< filter1={"=len(filter1)=2"}, id={"=count(distinct date)>=1"} >} distinct id)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

They may return different results when there is a one-to-many or many-to-many relation between id and filter1. 

The first expression is like making selections. The second expression is a  test of each id. 

Assume we have at least one id that associates with two filter1 values, having lengths of 2 and 5. 

The first expression would include this id, as it would be possible when the filter1 is "selected".  

The second expression would exclude this id, as the "len(filter1)" function would return zero or null. It would return zero as len() is not an aggregation function, so how to calculate two filter1 values with different lengths?

I would expect the second expression to return a smaller number as it would only include ids with a single filter1 value or all filter1 len=2.  The first expression would return ids where any filter1 had len=2.

When using an expression search {"=..} there is an implied Aggr() with the modifier field serving as the Aggr dimension.  If you look at it  that way, you can see these are quite different because of the dimension used:

Aggr(len(filter1), filter1)

Aggr(len(filter1), id)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

 

ioannagr
Creator III
Creator III
Author

Hi @rwunderlich . I have a couple of questions.

1) You said that "the first expression would include this id, as it would be possible when the filter1 is "selected".  "but if it works as selections, would it still include the id if i selected a value with the length of ,say,5 just because i selected something from filter1?

2) As for "The second expression would exclude this id, as the "len(filter1)" function would return zero or null. It would return zero as len() is not an aggregation function, so how to calculate two filter1 values with different lengths?"

i did not understand it all. Firstly, why it would return 0 or null (i don't get the logic, i would expect something like true or false? :/. And then why would i t be of concern to calculate two filter values with different lenghts at the time for each id?

 

 

I would really appreciate further information from you. Thank you so much.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

#1. Yes. 

#2. I'd like to post a nice example, but everytime I do my message won't post and gives me an error message about "Invalid HTML".  Seems to happen sometimes and I've never figured out why.

So what I can say is this. Imagine you have two rows with id and filter1 values like this. 

1 ab
1 abcedf

What is the value of len(filter1) for id 1?

ioannagr
Creator III
Creator III
Author

For my case, it's supposed to be 1-1, but in any other case... i don't really know, could be both 2 and 5, but i would only take into account the first one because i want in my set analysis to be equal to 2.

You said this would work: count({<  id={"=count(distinct date)>=1 and len(filter1)=2">} distinct id)

and not this: count({< filter1={"=len(filter1)=2"}, id={"=count(distinct date)>=1">} distinct id)

 

In my mind i think i'm *this* close to get it , thanks to you @rwunderlich ! 😁 Thanks for the patience