Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
jonathandienst
Partner - Champion III
Partner - Champion III

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

View solution in original post

5 Replies
Not applicable
Author

Did you tried the below script ?

Set vTemp='Value'

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

Anonymous
Not applicable
Author

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

sujeetsingh
Master III
Master III

The value is present or not confirm first.

jonathandienst
Partner - Champion III
Partner - Champion III

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
Anonymous
Not applicable
Author

Thanks for your replies!

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


Best regards,
Filip