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: 
brindlogcool
Creator III
Creator III

Variable

Hi ,

Is it possible to use the variable in the if condition like this

=If (Value='$(vName)', Result)

1 Solution

Accepted Solutions
IAMDV
Luminary Alumni
Luminary Alumni

Hi Again,

Now I understand what you mean (hopefully!). In my example, if you wanted to see all the Sales values for vTest variable then you need to use Concat function with Set Expression. However in your dataset if you have one-one relationship between the two fields then you can use ONLY function or any aggregation function.

Concat({<Months = {$(vTest)}>} Sales, ', ')

or

ONLY({<Months = {$(vTest)}>} Sales)

I'm attaching the updated QVW file. I hope this helps!

Cheers - DV

http://qlikshare.com

View solution in original post

11 Replies
IAMDV
Luminary Alumni
Luminary Alumni

Yes, you can use it. If you have expression in the variable then you can use the dollar sign expansion. If not, you can use :

=If (Value = vName, Result)

I'm assuming that "Value" is the field name in the above example.

Cheers - DV

brindlogcool
Creator III
Creator III
Author

Yes it is the field value

brindlogcool
Creator III
Creator III
Author

But does the Value column should have a default selected value ?

IAMDV
Luminary Alumni
Luminary Alumni

Hi Again,

Okay. What does the variable contain? Have you tried the above solution? Please post the sample QV document if you still have issues.

Answering your second question : It doesn't need to be default selction however, if you wanted to execute the condition based on field selection then you can use meta data functions in QlikView. I had made a video tutorial explaining more about meta data functions in QlikView. Here is the link :

http://qlikshare.com/241

Thanks,

DV

www.QlikShare.com

brindlogcool
Creator III
Creator III
Author

I tried it if the value is selected then it is working fine else it is not. File size is huge . i need to scrample it.It will take a lot of time. If you place some example it would be great.

IAMDV
Luminary Alumni
Luminary Alumni

Okay, so you don't want to make selection but you wanted to check if the condition evaluates true or false. Is this right?

Thanks - DV

IAMDV
Luminary Alumni
Luminary Alumni

If you need to check the field values hold the contents of variable as a condition without making a selection then you need something like this...

=IF(Concat(Value, ', ') like '*$(vName)*', Result)

I'm using the like operator with wild card - (*) to search if the variable contents exists within your Value field.

I hope this makes sense.

Cheers - DV

brindlogcool
Creator III
Creator III
Author

OK let me check , Result field is also a column name.Not the hardcoded value.

IAMDV
Luminary Alumni
Luminary Alumni

Hi Again,

I'm not sure if you wanted to display the "Result" field in TextBox or ListBox. However, I have created a sample QVW file for your reference. Please check the two variable I have used in the example. They are vTest and vCondition and please let me know if you have any questions.

Good luck!

Cheers - DV

www.QlikShare.com