Tech Tuesday: Adding Parameters to Excel Report Builder report
We have been asked many times if you can have parameters in an Excel Report Builder built report so the end user can restrict down the data a little easier.
With the core Excel Report Builder, this isn’t something that can be done. But, it can be added in Excel to the report you build in Excel Report Builder. Here is how you would go about doing that.
- Create an Excel Report Builder report with the data you need.
- Open the list in Excel and put the cursor in an empty cell.
- Click the Data tab.
- In the Get External Data portion of the ribbon, select From Other Sources – From Microsoft Query.
- Select Dynamics GP or <New Data Source> and click OK.
- On the SQL Server Login window, login to the SQL Server with a user that will have access to the view you have created for your Excel Report Builder setup. Click the Options button and then in the Database field select the database the view was created in. Click OK.
- In the Available tables and columns, select the view that was created in Excel Report Builder and insert it into the Columns in your query field.
- Click Next on the Choose Columns window, the Filter Data window, and the Sort Order window.
- On the Query Wizard â€“ Finish window, select Return Data to Microsoft Excel and click Finish.
- The Import Data window will open. Select New Worksheet for where to put the data and click OK.Â It will create a new worksheet that will look very similar to the one created by Excel Report Builder.
- Enter in Field headings for the parameters you want people to be enter.Â You can do it to the right of the data or insert rows/columns to put them in.
- Click the Data tab and select Connections in the Connections portion of the ribbon.
- Highlight the Query from Dynamics GP connection. It may be named differently if you selected to create a new one in step 5. Click Properties.
- On the Usage tab, mark Refresh data when opening the file and Remove data from the external data range before saving the workbook.
- Click the Definitions tab.
- In the Command Text box, scroll to the bottom of the query. Add your where clause. The ‘?’ is used for the parameter.
- For the example I am using, my where clause is: WHERE erbGLTransactions.OpenYear like ?
- The exact where clause is going to have to change a little based on the data types of the fields. For example, here is one for a string: where (STATE like (‘%’+?+’%’)) AND (CITY like (‘%’+?+’%’))
- Click OK. If prompted to login to the SQL server again, do so.
- When prompted to Enter a Parameter Value, click Cancel.
- In the Workbook Connections window, click Properties again on the Connection.
- Click the Definition Tab.
- Click the Parameters button.
- If the Parameters button is greyed out, click the Edit Query button and click OK or Cancel on any messages and close the Query window.
- Then click Parameters button.
- Highlight Parameter 1 and select Get the value from the following cell radial button
- Click in the field below the option to put the cursor in the field. Then in the background, click on the field in the Excel spreadsheet where the first parameter will get its data. It should populate the field with the cell. Mark the Refresh automatically when cell value changes check box.
- If you have additional parameters, set them the same way, but link to the correct field.
- Click OK to close the Parameters window.
- Click OK to close the Connection Properties window.
- If prompted to login to the SQL Server, do so and click OK.
- Select Close on the Workbook Connections window.
- Your parameter should now work and allow you to enter in an specific value to return the data.
Leave a Comment
Integrate & Automate without Any Code.
SmartList Data has Never Been Faster.
The Easiest Way to Report on GP Data.
Very good, Nicole. It’s easy to see why adding Parameters to Excel Builder is a bit of a problem. Thank you for the nice explanation of how to add them.
When creating this the UID is being saved in the Connection string. Is there a way to make this universal, so that the report uses the credentials of who ever opens it?