Stump the Panel: SharePoint Q&A

Immediate solutions for common SharePoint questions
It is currently Thu May 23, 2013 9:58 pm

All times are UTC - 5 hours [ DST ]


Forum rules


What you are viewing is an archive of Stump the Panel. It remains for reference purposes. Please post all new questions on NothingButSharePoint.com
https://www.nothingbutsharepoint.com/sites/eusp/Forum



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Filter webparts by month, last month, 2 months ago
PostPosted: Thu Apr 07, 2011 7:03 pm 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
Hi,
I'm going to create a list that will hold some data for our team, one of the columns will be mm/yyyy column.

I would like to create a page, that will have 3 DVWPs on it.
the first will be the current month, the next will be last month, and the 3rd will be 2 months ago.

Is there a way to filter a webpart that way? I've seen some of the date range methods, using -30 for days. But I haven't seen anything for -1 for month?

Is something like this possible?


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Fri Apr 08, 2011 5:38 pm 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
Anyone done this before?

I really want to try and make it so the page is pretty much self suffient and I don't have to update the filters when I add new content to the list.

The first DVWP would display everything for the current month, the second one would display everything from last month, and the third would display from 2 months ago.

Seems like this would be possible, but I'm having hard time locating any examples.


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 11:53 am 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
If the -1 month isn't an option, is there any other way to accomplish what I need?


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 12:58 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 6:02 pm
Posts: 1035
Location: Silver Spring, MD
This can be done and I've done it before. You'll have to hack at the CAML to get this to work right. A good thread to review would be:

http://social.msdn.microsoft.com/Forums ... fd65d7536/

You will have to add an <And> clause when you are doing 1 & 2 mos. prior. Just so you know, the CAML is contained within the selectcommand on each of your DVWP's. That is what you'll be updating. You may be able to use the GUI to actually create the filter, but when I did this previously, I used U2U and the post above.


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 1:40 pm 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
RemyMaza wrote:
This can be done and I've done it before. You'll have to hack at the CAML to get this to work right. A good thread to review would be:

http://social.msdn.microsoft.com/Forums ... fd65d7536/

You will have to add an <And> clause when you are doing 1 & 2 mos. prior. Just so you know, the CAML is contained within the selectcommand on each of your DVWP's. That is what you'll be updating. You may be able to use the GUI to actually create the filter, but when I did this previously, I used U2U and the post above.


Hi,
I've used that method before, but that was subtracting days from today. How do you do for months? I don't see it mentioned there?


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 2:55 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 6:02 pm
Posts: 1035
Location: Silver Spring, MD
For months you would have to ballpark your numbers or create a template that can determine the month value for you on the fly. If it has to be absolutely accurate, then I would create an xsl template that could determine the Month Days and then jam that value back into your CAML.

I've been told you can manipulate parameters using XSLT before the CAML is rendered, but I'm not going to say that can be done. I haven't tested that approach, but I have been assured this works. Your mileage may vary...


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 7:50 pm 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
RemyMaza wrote:
For months you would have to ballpark your numbers or create a template that can determine the month value for you on the fly. If it has to be absolutely accurate, then I would create an xsl template that could determine the Month Days and then jam that value back into your CAML.

I've been told you can manipulate parameters using XSLT before the CAML is rendered, but I'm not going to say that can be done. I haven't tested that approach, but I have been assured this works. Your mileage may vary...


ah OK, darn I was hoping there was an easier way to get it work with months.
I have no idea how I would create an xsl template that would determan the month days and put them back into the CAML.


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Mon Apr 11, 2011 9:48 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 6:02 pm
Posts: 1035
Location: Silver Spring, MD
Let me not steer you down the wrong path. What you need to do is follow the post from the MSDN forum. That will give you a date to start from. You will then have to write your own CAML that adds to the selectcommand.

Quote:
You will have to add an <And> clause when you are doing 1 & 2 mos. prior. Just so you know, the CAML is contained within the selectcommand on each of your DVWP's. That is what you'll be updating. You may be able to use the GUI to actually create the filter, but when I did this previously, I used U2U and the post above.

I would follow this approach to the "T". After you get the base query up and running from the MSDN forum, post your CAML here and I'll help you through it.

I'm thinking your other thread is directly related to this one. Is that the case?


Top
 Profile  
 
 Post subject: Re: Filter webparts by month, last month, 2 months ago
PostPosted: Tue Apr 12, 2011 12:38 pm 
Offline

Joined: Sun May 16, 2010 7:41 pm
Posts: 147
Hi,
I'll work on creating the CALM today, and post back.

Actually these are 2 different projects I'm working on.

The other one, I'm creating a newsletter draft for our writers to submit their content too. I want the page to display everything for the current newsletter. So to make it easy on the writers, as long as they put a submission date that is within the current week, I want it to display on the page.

This project; I'm adding data from a spreadsheet. We want to see 3 months worth of data, to see a trend. So I want to add 3 views to a page, 1 view for current month, the other for last month, and the 3rd view would be for the 2 months ago.

Thanks Again
Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group