SharePoint - Auto-increment dates in new records? - sharepoint

I have a list that's going to be updated with relatively static data weekly, and I wanted to create a workflow to do this automatically. The only field I'm having trouble with is Start Date.
I want the new Start Date to be exactly one week after the previous week's (row's) Start Date, but I can't figure out how to capture this. I can't seem to find an easy way to get the value of the previous row.
Now, theoretically, I could just have the workflow run once a week on a given day and use [Today] as the value for the field; however, a requirement is that the list can be populated a few weeks in advance if needed.
Thanks in advance for any help you can provide!

You could solve this problem by creating a custom Field type that queries its parent list for the most recent item and set itself to be the desired date. MSDN has a number of decent references for how to create custom field types.
I recently did something akin to this: I created a "Unique Number" field type that will ensure that no two rows contain the same numerical value in the same column.

Why not just query the list and order by date descending. The first row returned is the previous week's date?
The CAML Query would look something like this:
<Query>
<OrderBy>
<FieldRef Name='Modified' Ascending='False' />
</OrderBy>
</Query>
I use U2U CAML Query Builder for syntax help...

Related

Using Flow to filter a date time field in Sharepoint list

I have a Sharepoint which has a datetime field format d/m/yyyy.
I've connected to Sharepoint and want to use the filter query option to find items where the month and day are the same as the current month and day? The Flow will go through each item in the list and send a happy birthday message.
"formatdatetime(DateofBirth,'MM') eq formatdatetime(utcnow(),'MM')". This failed.
To compare two date in the flow, you need to add a "Filter Array" step under "Get items" step.The expression in the Filter Array as below:
#equals(formatDateTime(item()?['TestDate'], 'MM-dd'), utcNow('MM-dd'))
The 'TestDate' is my column.
Like this:
Reference:
https://powerusers.microsoft.com/t5/Building-Flows/How-to-compare-two-dates-by-month-in-a-quot-get-items-quot/m-p/151219#M15179

Filtering on a calculated field - Filter being ignored

I have spent a couple of days (no joke) trying to get a filter to work. I have two calculated fields in a list query. They are called totalFY and countFY, respectively. Here are the expressions for the fields:
totalFY: total ([Hard Credit] for [Constituent ID], [Date of Record Fiscal Year])
countFY: count (distinct [Date of Record Fiscal Year] for [Constituent ID])
When I drag totalFY to the detail filters panel, and set a threshold (let's say, >5000), my list query turns out the expected results, which would be customers whose total purchases for each year are greater than 5000.
But when I add the countFY field to the filter panel, it is completely ignored by the filter threshold I set (in this case, >2). I've tried several things over the past couple of days and am really stumped.
If I filter with only one or the other, each works fine independently. I've tried setting one to "apply filter after auto aggregation" but I get the same results.
Any thoughts would be greatly appreciated!
Thanks so much.
Solved. What I ended up doing was creating a new query and adding countFY from the previous query as a data item in the new one. Now I can filter effectively on countFY, and adjust the totalFY amount filter in the previous query. Hope this helps someone else out there.

How to sort by date in SOLR?

I want to sort the results and scores returning from SOLR search,how I can get scores based on date like below:
Suppose for keywords "football"
12-10-2012 - 3.2
13-10-2012 - 1.5
My solr date filed lis like below:
<field name="published_date" datetimeformat="dd-MM-yyyy" type="date" indexed="true" stored="true"/>
I checked this docs but couldn't find that.
Thanks.
You can pass the sort parameter in the URL
e.g. sort=published_date desc for documents by published date in descending order.
If you want to sort by score and date you can use sort=score desc, published_date desc
taken from the wiki
Although not technically a Syntax difference, please note that if you use
the Solr "DateField" type, any queries on those fields (typically range queries)
should use either the Complete ISO 8601 Date syntax that field supports,
or the DateMath Syntax to get
relative dates. Examples:
timestamp:[* TO NOW]
createdate:[1976-03-06T23:59:59.999Z TO *]
createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]
pubdate:[NOW-1YEAR/DAY TO NOW/DAY+1DAY]
createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z+1YEAR]
createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z]
NOTE:TO must be uppercase, or Solr will report a 'Range Goop' error.
combine that with this and the job is done :) it's pretty easy, it just requires some tries in the beginning
a little edit: this method allows you to retrieve values based on a date range and apply a score boost to them according to their values. apparently you were asking help on how to retrieve sort on base score and date, so my answer isn't the 100% correct one

Cognos-how to create a end report for a calendar with aggregation

I would like to create an end report, which shows a calendar(month) with aggregation for the specified data.
I am working on cognos 8.4, I have a requirement where I have to show the statistics of the month in a calendar form. The report should be dynamic and it should display the details of the particular month.
Any help or advice is highly appreciated.
Have you tried creating a crosstab? I would create an SQL view of your data to get something like this:
select amount, DayNumber, DayofWeek, MonthName, MonthNumber, YearNumber, Weeknumber
from your_view
Within Report Studio filter on YearNumber and MonthName (ordering by Monthnumber). Then create a crosstab where columns would be DayofWeek and rows would be Weeknumber. Inside the crosstab drag the amount field.
Remember Cognos auto-sumarize everything by default unless you override that behavior.
One thing I cannot think to figure it out is how to display the DayOfMonth within the crosstab. That one is tricky since the data is string and it is not groupable in any calculation (MAX, SUM, AVG, etc). If you can find a solution for that, please let me know. Cheers.
You can use a repeater table, and the table will use a query which gives you the dates, you can apply the filter in that query for the user-selected month. After you have that part working, you can pull a list into the repeater table and then use master-detail relationship from the date query to the list query, then you can design your list inside the table.

sort by date in caml query

I want to sort my list items by date:
I m using
<OrderBy><FieldRef Name='SortDate' Ascending='True'/></Order By>
but its giving me results randomly.Is it possible to sort by date in CAML if not then if there is any other way to retrieve list items sorted on the basis of date....
Yes you can sort by date using CAML. To test it out try sorting on the Modified field to see if that gets you better results. Is your SortDate field an actual DateTime field, or is it something else like a string?

Resources