Using parameters in the SQL Statements via Power Query in Excel

  • 16 October 2023
  • 0 replies
  • 19 views

Userlevel 1
Badge

In certain situations, you may find the need to run a SQL Statement with conditions, like a StartDate and EndDate, and import the resulting data into Excel. Additionally, taking it a step further, reading input parameters directly from the Excel sheet can significantly simplify the data refresh process, eliminating the necessity to modify the query each time.  

The following article provides a step-by-step guide on how to accomplish this using the CData ODBC Driver for SageIntacct. 

  1. After installing the driver and setting up the DSN Configuration, in Excel, open the Data tab and choose Get Data -> From Other Sources -> From ODBC  

  1. Choose the DSN name you have just created from the first step and expand the Advanced options to create the SQL statement. 

     

 

 

 

 

 

  1. Click OK, then select Load To, and decide on your preferred data visualization method (Table, PivotTable Report, PivotChart). When specifying the data destination (Existing or New Worksheet), be sure to allocate some empty rows for future use with input parameters.

     

     

 

  1. Once you've successfully loaded the data into the Excel sheet, the next step is to refresh it with different Start_Date and End_Date values. You'll need to select two cells and rename them as follows:  

 

  1. Select the cell that you want to name. 

  1. Click the Name box at the left end of the formula bar. 

  1. Type the name (ex. StartDate) you want to use to refer to your selection. 

  1. Press ENTER. 

  1. Do the same for the EndDate. 

 

 

  1. Input the updated values for the Date parameters into the cells you've renamed. 

 

 

 

  1. Open the Power Query Editor, proceed to the Advanced Settings, and make the following adjustments to the query:     

     

 

 

  1. Click "Done" and proceed while opting to ignore the privacy level checks for this file. 

 

 

 

  1. Click Close&Load to import the data into the Excel sheet. When you modify the values in the cells you renamed, the data will be filtered based on the specified criteria. 


This topic has been closed for comments