Open a report and modify the value for Now to change the reference time using the Vizubi API

Summary

This article demonstrates how to open a Vizubi Database and view a Vizubi Report with the columns Country, TY TotalPrice, PY TotalPrice. You can also learn how to set the value of the OrderDate Now variable and refresh the report with Sales corresponding with the new date. In Vizubi you can change the reference date for “today” thus shifting between different time perspectives; we will change the value of the OrderDate Now variable from 01/10/2010 to 01/10/2007. The report starts showing sales for 2010 vs. 2009 and ends up showing sales for 2007 vs. 2006.

Using the Sample Application

Let’s get started by looking at the sample application that is supplied with this article.

First, we will need to ensure that your machine has all of the necessary prerequisites:

- You will need to have Visual Studio 2005 or Visual Basic 2010 Express installed.
- You will also need to install Vizubi API Setup latest version.

After installing the prerequisites, unzip the sample files to a directory on your local hard disk.

Now, we’re ready to walk through the sample.

Open the VizubiTimeDimension.sln

media_1285748199928.png

Open the VizubiTimeDimension\VizubiTimeDimension.sln solution.

The solution contains one project which is an executable that allows you to open the “Vizubi_Sample.ndb” Vizubi Database, open a Vizubi Report named “Report2” and convert the result to a DataTable that is displayed in a DataGridView.
The project allows you to change the value for the OrderDate Now TimeDimension variable and immediately calculate the change in TY Sales and PY Sales.
The project also contains the implementations for closing the Vizubi Report and the Vizubi Database and for handling errors and memory release.

Run the application

media_1285749696079.png

Select the Debug | Build VizubiTimeDimension menu item, and then press F5 to run the application.

Open the db and the report

media_1285917767233.png

When the application runs, it opens a single Form. Click the Open Database button and then the Open Report button to populate the DataGridView with the Report2 Dataset from the Vizubi Database named Vizubi_Sample.ndb.

On the left, in the frame labeled Time Dimension variable used in the report, you can see the variable used in the report for managing the OrderDate Now TimeDimension, its current value and the ranges used in the report (TY and PY) and the corresponding values (in the image above TY is equal to 2010 and PY is equal to 2009).

Change the OrderDateNow Variable

media_1285918452428.png

You can change the value for the OrderDate Now Variable by clicking on the down arrow next to the date and opening the DateTimePicker1 component; then select the date you want or enter the date in the text box to the left of the date.

Apply changes and view results

media_1285918529016.png

To apply the new value to the OrderDate Now variable, just press the Enter key on the DateTimePicker component or click the Set date for OrderDate Now Button. The report will be reloaded with the new values for the columns TY TotalPrice and PY TotalPrice.

Please note that:
-    Some Countries will disappear if they do not have sales in both the current year and in the past year (in this case Belgium has no sales in the 2006 or in 2007).
-    Some Countries have TY TotalPrice or PY TotalPrice equal to zero because the sum of TotalPrice in the corresponding year is zero.

Summary

This article demonstrates how to open a Vizubi Database and view a Vizubi Report with the columns Country, TY TotalPrice, PY TotalPrice. You can also learn how to set the value of the OrderDate Now variable and refresh the report with Sales corresponding with the new date. In Vizubi you can change the reference date for “today” thus shifting between different time perspectives; we will change the value of the OrderDate Now variable from 01/10/2010 to 01/10/2007. The report starts showing sales for 2010 vs. 2009 and ends up showing sales for 2007 vs. 2006.

Using the Sample Application

Let’s get started by looking at the sample application that is supplied with this article.

First, we will need to ensure that your machine has all of the necessary prerequisites:

- You will need to have Visual Studio 2005 or Visual Basic 2010 Express installed.
- You will also need to install Vizubi API Setup latest version.

After installing the prerequisites, unzip the sample files to a directory on your local hard disk.

Now, we’re ready to walk through the sample.

Open the VizubiTimeDimension.sln

media_1285748199928.png

Open the VizubiTimeDimension\VizubiTimeDimension.sln solution.

The solution contains one project which is an executable that allows you to open the “Vizubi_Sample.ndb” Vizubi Database, open a Vizubi Report named “Report2” and convert the result to a DataTable that is displayed in a DataGridView.
The project allows you to change the value for the OrderDate Now TimeDimension variable and immediately calculate the change in TY Sales and PY Sales.
The project also contains the implementations for closing the Vizubi Report and the Vizubi Database and for handling errors and memory release.

Run the application

media_1285749696079.png

Select the Debug | Build VizubiTimeDimension menu item, and then press F5 to run the application.

Open the db and the report

media_1285917767233.png

When the application runs, it opens a single Form. Click the Open Database button and then the Open Report button to populate the DataGridView with the Report2 Dataset from the Vizubi Database named Vizubi_Sample.ndb.

On the left, in the frame labeled Time Dimension variable used in the report, you can see the variable used in the report for managing the OrderDate Now TimeDimension, its current value and the ranges used in the report (TY and PY) and the corresponding values (in the image above TY is equal to 2010 and PY is equal to 2009).

Change the OrderDateNow Variable

media_1285918452428.png

You can change the value for the OrderDate Now Variable by clicking on the down arrow next to the date and opening the DateTimePicker1 component; then select the date you want or enter the date in the text box to the left of the date.

Apply changes and view results

media_1285918529016.png

To apply the new value to the OrderDate Now variable, just press the Enter key on the DateTimePicker component or click the Set date for OrderDate Now Button. The report will be reloaded with the new values for the columns TY TotalPrice and PY TotalPrice.

Please note that:
-    Some Countries will disappear if they do not have sales in both the current year and in the past year (in this case Belgium has no sales in the 2006 or in 2007).
-    Some Countries have TY TotalPrice or PY TotalPrice equal to zero because the sum of TotalPrice in the corresponding year is zero.

Need more help?