Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have an expression like this :
count(distinct
employee( {<
employee= {"len(aggr(max( promotiondate),employee))=0"},
otherfield = {5},
otherfield2= {'text'},
employee= {"=startdate < addyears(now(),-1)"}>}
employee)
the result is that all employees are counted , which is wrong
when I move the last modifier to the top so it will be
count(distinct
employee( {<
employee= {"=startdate < addyears(now(),-1)"},
employee= {"len(aggr(max( promotiondate),employee))=0"},
otherfield = {5},
otherfield2= {'text'}
>}
employee)
the correct result is given.
Now my question is, does the sequence matter ?
What you are doing is not correct possibly for multiple reasons. But I would answer w.r.t your specific question. Sequence of modifiers (fields) matters when you are using the same field more than once. And only the latest one is considered in set analysis. For ex: If you write :
Sum({<Sales={">500"}, Sales={">100"} >}Sales)
the latest Sales condition (highlighted) is considered in set analysis.
@curiousfellow I am not sure how it will give you correct results, but the fact is that when you are evaluating different modifiers using same field (like in your example it is employee), second modifier overrides the first modifier condition as first modifier also evaluating on same field. This is where sequencing is considered where both modifiers using same field (which generally we don't do that).
When you use different fields in set modifier then sequence doesn't really matters because it works as AND condition so that if you change the sequence also it's gonna give you same results.
In you below expression ,only second highlighted set modifier will be evaluated as both first and second modifiers are using same field(employee)
count(distinct
employee( {<
employee= {"=startdate < addyears(now(),-1)"},
employee= {"len(aggr(max( promotiondate),employee))=0"},
otherfield = {5},
otherfield2= {'text'}
>}
employee)
If you change one of the modifier field like below then sequence really won't change your end results
count(distinct
employee( {<
ID= {"=startdate < addyears(now(),-1)"},
employee= {"len(aggr(max( promotiondate),employee))=0"},
otherfield = {5},
otherfield2= {'text'}
>}
employee)
Having said that, yes, sequence matters but actually not because we always use different field names in modifiers. May be you can share the scenario so that we can suggest the possible expression you can use.
Thank you both for your answer, I did not know this. Probably explains why I am always struggling with this kind of modifiers 🙂 . I can use different fields. I tried...and it works.
Can I use any field in the first part of the modifier ? ( field = {"=....
Just adding Help doc link for Modifiers, so you can look that over too, as that is the official doc on how things work and will hopefully provide some further guidance:
The only other thing I can suggest is reviewing the Design Blog area too, just use the following URL and search on Set Analysis, these posts are from our internal experts and may have some additional information that may prove helpful too:
https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog
Sorry I do not have something better, but hopefully this may close things out. Be sure to close the thread if you do have what you need by using the Accept as Solution button on the post(s) that helped, as this gives credit to the folks answering posts and lets others know what did help.
Regards,
Brett