11 Replies Latest reply: May 14, 2012 3:33 PM by Deepak Vadithala RSS

Variable

Brindlogcool

Hi ,

 

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

 

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

  • Re: Variable
    Deepak Vadithala

    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

    • Variable
      Brindlogcool

      Yes it is the field value

      • Re: Variable
        Deepak Vadithala

        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

        • Variable
          Brindlogcool

          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.

          • Re: Variable
            Deepak Vadithala

            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

            • Re: Variable
              Deepak Vadithala

              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

              • Variable
                Brindlogcool

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

                • Re: Variable
                  Deepak Vadithala

                  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

                  • Variable
                    Brindlogcool

                    Hi DV,

                     

                    Thanks for all your response.Sorry if i have not provided  the clear details. Consider your example you  have given vTest as Jan , so the object TX10 should have sales output related to Jan. but it is displaying all the sales data. that is the problem. I want to show only Jan related data in TX10.Please let me know if still you need more clarity .

                    • Re: Variable
                      Deepak Vadithala

                      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

    • Variable
      Brindlogcool

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