Welcome to MSDN Blogs Sign in | Join | Help

A PivotTable Trick That Brings Data Validation to Excel Services

Today's author: Dany Hoter, a product planner who works on the Excel Services team. 

Excel has a feature called Data Validation that controls the possible values a user might enter into a cell or a range of cells.

As you can see there are many options for validating data entry. The most popular is probably validating against a list of values. The list can be included in the validation definition or can be a region in the sheet referenced from the dialog.

Recently I saw an example created by a customer that validates input using a PivotTable instead of data validation. The idea is to use only the report filter area of the PivotTable and to use the values selected in multiple filter fields as inputs for a model:

In the example you see multiple input fields and when clicking the filter icon the user will see a list of values and can choose one.

The advantage of this method is easier maintenance of multiple lists of values used for validating multiple fields. The range that the PivotTable is based on looks a bit odd because usually PivotTables are based on rectangular ranges and not something that looks like this:

In order to avoid the "(blank)" value appearing in the PivotTable drop-down list of values, fill the last value in each category all the way down to the last row of the region:

Use of PivotTable for validation in Excel Services

So far I explained how a PivotTable could be used as a validation method in Excel. The impact of using this technique is not significant until we apply it to Excel services. Excel services does not support data validation and any workbook containing data validation will not be loaded by Excel Calculation Services (ECS). In addition, entering inputs to a model in Excel Services is not as user-friendly as Excel since values cannot be entered directly into cells. Using PivotTable filters for validation is fully supported in Excel Services and can solve these two problems. We have a friendly way to input values into a model and also to apply a validation against a list of values. The same example might look like this in the browser:

So if you are looking to build a spreadsheet that can be consumed by Excel Services and provides user-friendly, validated, input, give the PivotTable report filter a try.

Update: sample file can be found here.

Published Wednesday, February 13, 2008 12:50 AM by Joseph Chirilov

Comments

# BioSensorAB » A PivotTable Trick That Brings Data Validation to Excel Services

# A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, February 13, 2008 8:00 AM by Windows Vista News

Did you see this post at blogs.msdn.com

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, February 13, 2008 11:26 AM by Colin Banfield

This might be an interesting technique for overcoming one of the validation list feature shortcomings i.e. mindlessly displaying everything in a list, including duplicates.  

However, how do you prevent multiple or all selections? In the vast majority of cases, you want the user to select a single item that serves as a precedent to other cells in the workbook or perhaps as a parameter for filtering an external data source.

You can solve the issue using VBA, but this introduces an additional complication into the equation and also means that any VBA solution can't be used in Excel Services.

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, February 13, 2008 12:13 PM by Mike Alexander

Nifty trick.  However...(there's always a however isn't there?)

It would be even better if one filter dropdown in the pivot table served as a parameter for the others (like cascading combobox selections).

I believe this is desparately need functionality in PivotTable filters. Currently, one has to resort to VBA or wonky formulas.

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Thursday, February 14, 2008 5:08 AM by Alex

Would you also post a sample sheet for download?

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Friday, February 15, 2008 7:01 AM by sam

Joseph,

1) So what happens when someone manually types data in the dropdown...

"No item exists....do you want to rename this to that" unless you keep slect multiple items ticked....

2) Why does every thing in this blog eventually gets linked to Excel Services....

3)When will be able to get some new features in Data validation.....nothing has changed for the last 10 years

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Friday, February 15, 2008 2:25 PM by Neal O

Looks a complete waste of space - if you need to use this kind of 'cheat' to do somthing so simple does not the finger point at Excel Services? Time for a more fundemental rethink or what?

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Friday, February 15, 2008 6:28 PM by A User

Nice hack on a defficiency of Excel Services. If only it did not require so many hacks, I might use it.

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Friday, February 15, 2008 8:11 PM by Joseph Chirilov

Colin: You are right, there is nothing preventing a user from making multiple selections.  That said, this still provides much more guided interaction with spreadsheets on Excel Services than was previously capable.  It's not perfect - I suppose that's why I called it a 'trick' and not a full-fledged workaround. :)

Mike: I agree, there are scenarios where that sort of functionality would be desireable.

Alex: I'm working on posting the example used in this post.

sam:

1) Interesting, I hadn't tried that myself. :)

2) We try to cover topics for both Excel and Excel Services. Looking over posts from the last couple months, it doesn't appear that Excel Services is in the majority of posts.  Excel Services is a "version 1" product so we would like to get as much helpful information out there into the community as possible.  That said, I don't think this has been done at the expense of Excel coverage.  In fact, my next post will be about Charts. (stay tuned!)

3) We're always accepting feedback/wishes for future improvements, so if you have anything to share we'd love to hear it.  Unfortunately, I can't yet comment on what's coming for the next release as we haven't started talking about it publicly yet.

Neal: Please keep in mind that Excel Services is a "version 1" product.  While we would have loved to support every feature of the Excel client, the Excel client represents 20+ years of development effort and it just wasn't technically feasible for us to achieve parity in the first release.  Our goal is that over time we will close the gap and bring more and more Excel functionality to Excel Services.

A User: Please see my reply to Neal.  If you have any specific feedback on which exact features keep you from using Excel Services, I would love to hear it.  Thanks.

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Friday, February 15, 2008 9:47 PM by Colin Banfield

A User: Please see my reply to Neal.  If you have any specific feedback on which exact features keep you from using Excel Services, I would love to hear it.  Thanks.

1) VBA

2) VBA

3) VBA

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Saturday, February 16, 2008 11:25 AM by Neal O

Try also

for iSuggest = 1 to forever

 msgbox "VBA", vbExclamation

next iSuggest

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, February 20, 2008 2:00 PM by James

Thank you.

This has helped me a lot.

# Example file for PivotTable / Data Validation Trick

Tuesday, March 04, 2008 10:10 PM by Microsoft Excel

Recently I posted an article discussing how PivotTables can be used on Excel Services to mimick the Data

# Example file for PivotTable / Data Validation Trick

Tuesday, March 04, 2008 10:43 PM by Noticias externas

Recently I posted an article discussing how PivotTables can be used on Excel Services to mimick the Data

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, March 05, 2008 3:34 AM by jmvdkolk

The Pivot table is really powerfull. But to get to the real power I would need to automate generating the Pivot tables. Recording a macro for creating a Pivot table generates code that does not work. I have not found any references anywhere on how to automate Excel Pivot tables. Anyone know of a book or a web page that describes this?

# re: Recording Pivot Table Macro

Wednesday, March 05, 2008 1:20 PM by Neal O

jmvd.. I'm not sure what u want to do. r u just talking within Excel or excel services where no 'macros' ie VBA exists. If u r talking straight Excel what r u trying to achieve? Is it on this strand, ie for use in validation for Excel Services or just a general thing? If its general I suggest u try Mr Excel bbs instead of here.

Neal

# re: A PivotTable Trick That Brings Data Validation to Excel Services

Wednesday, March 05, 2008 1:23 PM by Roger Govier

Very neat trick for using Pivot Table.

If you use XL2003, you avoid the Multiple selection problem, and being able to overtype the options presented.

You do need to hide the rows where the rest of the "PT skeleton" normally show.

New Comments to this post are disabled
 
Page view tracker