Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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.
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.
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>
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.