Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
pkrouglov
Contributor
Contributor

Set analytics inside IF statement does not reflect identifier.

I wanted my expression to show results only over two dimensions. Ones that are declared in the chart.

Dimensions: val, Entity

Expression:

if(

  val=2

  ,Count({1<EnterDTM={'>=$(=Date(vToDate-29))'}>} DISTINCT Code)/30

  ,if(

  val=1

  ,Count({1<EnterDTM={'>=$(=Date(vToDate-2))'}>} DISTINCT Code)/3

  ,if(

  val=3

  ,Count({1} DISTINCT Code)/vNumberOfDays

  ,0

  )))

However the result is reflecting all selections. What is wrong?

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try this:

if(

  only({1}val)=2

  ,Count({1<EnterDTM={'>=$(=vToDate-29)'}>} DISTINCT Code)/30

  ,if(

  only({1}val)=1

  ,Count({1<EnterDTM={'>=$(=vToDate-2)'}>}DISTINCT Code)/3

  ,if(

  only({1}val)=3

  ,Count({1} DISTINCT Code)/vNumberOfDays

  ,0

  )))

val is a field too, so it is aggregated by default with the only() function if you don't specify an aggregation function. And that means it will be affected by selections.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

Usually variables are used in a dollar expansion: $(vToDate). But I can't say from just what you posted what's wrong. I have no idea how you defined your variables.  Do the separate count expressions work? Perhaps you can post a small qlikview document that illustrates the problem.


talk is cheap, supply exceeds demand
pkrouglov
Contributor
Contributor
Author

Hi,

Please, find attached "set analysis and if sample.qvw".

Expected result is that

In the chart "Updated records per day" values does not change according to

Attribute_Name and YearMonth selections.

However, the chart changes according those selections.

In the chart "Last 3 days" I am using the same expression, but w/o IF:

Count({1<EnterDTM={'>=$(=vToDate-2)'}>}DISTINCT Code)/3

and values are not changing by the Attribute_Name and YearMonth selections.

Pavel Krouglov

On Fri, Jan 8, 2016 at 8:08 PM, Gysbert Wassenaar <qcwebmaster@qlikview.com>

Gysbert_Wassenaar

Try this:

if(

  only({1}val)=2

  ,Count({1<EnterDTM={'>=$(=vToDate-29)'}>} DISTINCT Code)/30

  ,if(

  only({1}val)=1

  ,Count({1<EnterDTM={'>=$(=vToDate-2)'}>}DISTINCT Code)/3

  ,if(

  only({1}val)=3

  ,Count({1} DISTINCT Code)/vNumberOfDays

  ,0

  )))

val is a field too, so it is aggregated by default with the only() function if you don't specify an aggregation function. And that means it will be affected by selections.


talk is cheap, supply exceeds demand