Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New 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
Highlighted
MVP & Luminary
MVP & Luminary

Re: Set analytics inside IF statement does not reflect identifier.

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
Highlighted
MVP & Luminary
MVP & Luminary

Re: Set analytics inside IF statement does not reflect identifier.

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
Highlighted
New Contributor

Re: Set analytics inside IF statement does not reflect identifier.

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>

Highlighted
MVP & Luminary
MVP & Luminary

Re: Set analytics inside IF statement does not reflect identifier.

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