Qlik Community

QlikView Integration

Discussion Board for collaboration on QlikView Integration.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

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.selectionValue.Count; j++)

          {

                        selectedFields.Add();

                        selectedFields.Text = @selection.selectionValue.ToString();

          }

         qvField.SelectValues(selectedFields);

}


1 Solution

Accepted Solutions
Not applicable

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.selectionValue.Count; j++)

     {

         selectedFields.Add();

         string val = @selection.selectionValue.ToString();

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

         {

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

           selectedFields.IsNumeric = true;

   }

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

         {

             selectedFields.Number = number2;

             selectedFields.IsNumeric = true;

         }

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

         {

            selectedFields.Number = number;

            selectedFields.IsNumeric = true;

         }                    

         else

         {

            selectedFields.Text = val;

            selectedFields.IsNumeric = false;

         }

     }

     qvField.SelectValues(selectedFields);

}

4 Replies
fdelacal
Valued Contributor

Re: select a date value in QlikView

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

This is better to see for qlikview.

Hope that helps you

Not applicable

Re: select a date value in QlikView

Facundo de la cal, good idea, but it doesn't work for me.

Here I havwe a try with a number, the selection of a number is also not working

if(Double.TryParse(selection.selectionValue.ToString(), out number))
{

                            ausgewaehlteFelder.Number = number;

}

Not applicable

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?

Not applicable

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.selectionValue.Count; j++)

     {

         selectedFields.Add();

         string val = @selection.selectionValue.ToString();

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

         {

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

           selectedFields.IsNumeric = true;

   }

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

         {

             selectedFields.Number = number2;

             selectedFields.IsNumeric = true;

         }

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

         {

            selectedFields.Number = number;

            selectedFields.IsNumeric = true;

         }                    

         else

         {

            selectedFields.Text = val;

            selectedFields.IsNumeric = false;

         }

     }

     qvField.SelectValues(selectedFields);

}

Community Browser