4 Replies Latest reply: Aug 7, 2013 9:13 AM by Steffen Prendke RSS

    select a date value in QlikView

      Hey together,

      I am using some OCX Code to make a selection in my QlikView-Application, it is working so far for me. But now I have discover some problems, I have try to select some date value e.g. 2011-01-03, this selection won't be work by my code, is there some workaround???

      //clear selection on my QlikView-App

      qvDoc.ClearAll();

      //I have declared some object with holds the information about the selection, that must be selected
      for (int i = 0; i < selection.Count; i++)

      {

           Field qvField = qvDoc.GetField(QLIKVIEWFIELD);

                IArrayOfFieldValue selectedFields = qvField.GetNoValues();

                for (int j = 0; j < selection[i].selectionValue.Count; j++)

                {

                              selectedFields.Add();

                              selectedFields[j].Text = @selection[i].selectionValue[j].ToString();

                }

               qvField.SelectValues(selectedFields);

      }


        • Re: select a date value in QlikView
          facundo de la cal

          Try to do the num(2011-01-03) in other field.

           

          This is better to see for qlikview.

           

          Hope that helps you

          • Re: select a date value in QlikView

            I play a little bit with the OCX API, something that I recognized was. That I am can select one Date value or number from a certain field.

             

            Field qvField = qvDok.GetField(SOME_QLIKVIEW_FIELD);

            qvField.Select("2011-03-01");

             

            This is a little strange I think, maybe there is some bug in the API?

             

            • Re: select a date value in QlikView

              DateTime dateTime;

              Double number;

              Int32 number2;

              for (int i = 0; i < selection.Count; i++)

              {

                   Field qvField = qvDoc.GetField(QLIKVIEWFIELD);

                   IArrayOfFieldValue selectedFields = qvField.GetNoValues();

                   for (int j = 0; j < selection[i].selectionValue.Count; j++)

                   {

                       selectedFields.Add();

                       string val = @selection[i].selectionValue[j].ToString();

                 if (DateTime.TryParse(val, out dateTime))

                       {

                          selectedFields[j].Number = Convert.ToDouble(qvDoc.Evaluate("=num('" + val  + "')"));

                         selectedFields[j].IsNumeric = true;

                 }

                       else if (Int32.TryParse(val, out number2))

                       {

                           selectedFields[j].Number = number2;

                           selectedFields[j].IsNumeric = true;

                       }

                       else if (Double.TryParse(val, out number))

                       {

                          selectedFields[j].Number = number;

                          selectedFields[j].IsNumeric = true;

                       }                    

                       else

                       {

                          selectedFields[j].Text = val;

                          selectedFields[j].IsNumeric = false;

                       }

                   }

                   qvField.SelectValues(selectedFields);

              }