Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

ateafilar
New Contributor III

Field selection as if clause in expression

Hi!

I have an expression in one of my objects that look like this:

IF(vVar=1,sum(IF(StatusChange<>'Deleted',Revenue)),sum(IF(StatusChange<>'Deleted',Contribution)))

It has worked fine, until today when I realized that using a bookmark didn't trigger my variable that is defined when selecting a specific field, call it Field1. In other words, when I select Field 1 (which is a check box) I have a trigger on that field that are setting the variable vVar = 1.

Instead of using the variable vVar as IF clause I would like to use the value of the field as IF clause to use either Revenue or Contribution as stated above. Something like:

IF(Field1='Value',sum(IF(StatusChange<>'Deleted',Revenue)),sum(IF(StatusChange<>'Deleted',Contribution)))

.. but I can't get it work. How to do this?

Thanks in advance!

Best regards,

Filip

1 Solution

Accepted Solutions
MVP
MVP

Re: Field selection as if clause in expression

Hi

Without your qvw or at least a sample and you don't describe the object in which the problem is occurring, so I can only guess - but here goes. I suspect that you have more than one possible value of Field1in the object at the point where you are trying to evaluate the expression.

If you want to detect if something is selected in Field1, you can use GetSelectedCount(Field1) or GetPossibleCount(Field1).

If you want to detect the one and only value selected, try If(Only(Field1) = 'Value',..)

If you want to detect if Field1 is one of several possible values, then use something like this

If(WildMatch('.' & Concat(Field1, '.') & '.', '*.Value.*'), ....)

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
5 Replies
Not applicable

Re: Field selection as if clause in expression

Did you tried the below script ?

Set vTemp='Value'

IF(Field1=$(vTemp),sum(IF(StatusChange<>'Deleted',Revenue)),sum(IF(StatusChange<>'Deleted',Contribution)))

ateafilar
New Contributor III

Re: Field selection as if clause in expression

I'm sorry, it doesn't work..

sujeetsingh
Honored Contributor III

Re: Field selection as if clause in expression

The value is present or not confirm first.

MVP
MVP

Re: Field selection as if clause in expression

Hi

Without your qvw or at least a sample and you don't describe the object in which the problem is occurring, so I can only guess - but here goes. I suspect that you have more than one possible value of Field1in the object at the point where you are trying to evaluate the expression.

If you want to detect if something is selected in Field1, you can use GetSelectedCount(Field1) or GetPossibleCount(Field1).

If you want to detect the one and only value selected, try If(Only(Field1) = 'Value',..)

If you want to detect if Field1 is one of several possible values, then use something like this

If(WildMatch('.' & Concat(Field1, '.') & '.', '*.Value.*'), ....)

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
ateafilar
New Contributor III

Re: Field selection as if clause in expression

Thanks for your replies!

GetSelectedCount(Field1) solves my problem as Field1 is a checkbox with only one possible value.


Best regards,
Filip

Community Browser