Thursday, March 26, 2009

How to filter a list on a specific date range (End User)

I have decided to add some end user focused entries as well for things that I get asked a lot...

I was asked recently about creating a filter on a list view for a specific date range.

To make a filter for a specific month you can do this:



You can also use the [Today] keyword in your filter. For example to create a view that shows all items with a date after the current date you would set your filter to date is greater than: [Today]. Or to have a filter show items in the last week you would set a filter for date is greater than [Today]-7 AND date is less than [Today]+1. Be careful to not put any spaces between the keyword and the - or + operator.

Remember to make sure your dates are in the correct format (mm/dd/yyyy) and are valid dates (ie 2/30/2009 won't work) otherwise you will get the "filter value is not in a supported date format" error.

Hopefully this help clarify any confusion that people may have.

Wednesday, March 11, 2009

Why can't I use Totals on a calculated column?

So you may have run into this frustration before: for some crazy reason, when creating views with Totals, you cannot include totals for Calculated columns (even if they are set to output as 'Number'!).

Here is a example situation:
You have a list of projects, each project has Q1 through Q4 values that you want to add up to give you a yearly total:



Easy enough, you just create a calculated column:



Now your list looks like this:


Here is where the frustration comes in, you want to see an average yearly spend so you create a view with Totals, unfortunately the calculated field doesn't even show up as an option!



This seems to me like an oversight from the product team, but at least there is an alternative method! If you view your list in datasheet view:



you can enable Totals here:



And magically your calculated column total shows up! Of course we wanted an average here, so just click the dropdown on your calculated column total field, and change the value to Average:



And there you have it. Be aware that for some odd reason the total will only display in datasheet view (if you change it back the other column totals stay but the calculated one disappears), but now you know how to find it.

Tuesday, March 3, 2009

Dataview DataSource not showing all files...

Ran into a situation today where a Dataview web part was showing some of the items in a Library but not all... It turns out that by default the datasource only shows files and folders at the top level. All of the items that are inside of folders or subfolders will not get returned.

The solution is to go to the 'Scope' parameter of your tag and change it to 'RecursiveAll'. This will cause your query to return all items regadrless of folder level from the data source. One thing to note, if your list or library is a Very Large List you need to be careful to set your 'Filter' parameters before changing the tag to 'Recursive' (Shows all files of all folders) or 'RecursiveAll' (Shows all files and all subfolders of all folders); in our case we were doing a dataform for a very large list so we set the Filter to ID = . If you are creating your DataSource in SPD and you don't set your Filter before changing the Scope to Recursive there is a good chance SPD will time out and/or crash trying to preview your data.

More info on Data Source configuration here: http://office.microsoft.com/en-us/sharepointdesigner/HA101326861033.aspx (just note that they are changing their data source properties BEFORE they add it to the page, this will run you into the timeout issue I described above for Very Large Lists so remember to add it to the page and edit the Scope by hand in Code View).