Sharepoint calculated field long time to calculate - sharepoint

I have made a SharePoint list that has a calculated field that is used as a unique identifier for each item. The field is calculated using the item id. The formula is as follows:
="TY0"&(TEXT([ID]+3200,"#####"))
The problem is that the calculation is seeming to take 20 mins or longer to happen. The field will show as "TY032000" until he calculation happens. If the field is changed via settings or SP designer and then changed back to the original formula, the calculation happens with no issues.

Same answer and some more workarounds at: columns dereferencing in SharePoint's calculated column
It is not 20 minutes, you can wait forever if an Item is never changed.
ID is empty for NEWly created items because the Formulas run BEFORE the Item is written to the List where it gets its ID value.
ID is not listed as an available Column when you create a Calculated Column.
As you experience, ID is updated when an Item is changed.
So add a Workflow which updates (anything in) the Item on New Item creation to trigger update of the Formula (now using the correct ID value)

Related

How to create a number field with prefix (ex: 00001) that increments whenever a document is added in SharePoint Online?

I created a calculated column and concatenated the id with a prefix, but it didn't work as expected.
The reason was that whenever i upload a file, the formula in calculated field that contains the ID with the prefix is executed, then SharePoint creates the ID.
So, the ID is being calculated as empty and only the prefix is showing.
What I used:
=CONCATENATE(REPT("0",MAX(0,5-LEN(ID))),ID)
What i would like to create is a number field with a prefix (ex: 00001) that increments whenever a document is added in SharePoint Online.
In other words, it's like the ID column in a list but with a prefix of five digits.
Therefore, is there any solution for this problem?
Thank you 😁.
Using the calculate column formula, when creating an new item, the ID column and the calculate column are created at the same time, so the value of the ID column cannot be obtained, so the calculate column will be displayed as 0.
But you can solve this problem by creating a flow.
Please refer to the screenshot below:

Subtracting value across multiple lists in Sharepoint 2010

I am attempting to perform a simple subtraction function across two lists in Sharepoint 2010.
I have one list called Inventory that has part number, part name, and quantity.
I have a second list called Tasks that has title, description, status, used part, and quantity.
I have a workflow rule that states the following:
The issue is that it's just throwing an error when I run a test task with a status of completed, used part selected, and quantity field holding an integer value.
I am creating the workflow and attached it to the Tasks lists, so all current item equal items in the tasks.
The end of update item in Inventory I am setting the variable New Inventory to be the new value of quantity in the Inventory lists.
Any help with this would be great. Thanks.
Disregard, found out during the CurrentItem: Quantity lookup i had set the part name to string instead of lookup value.

Get the average monthly value from 2 SP List columns and display in new column

I need to calculate the average value for each month. Currently I have 2 columns "DATE" (date value e.g 01/01/2010) and AccOpen (number value). So for all dates within January I need to return the average value of all numbers contained in the corresponding AccOpen rows for January dates.
Is it possible to use the CALCULATED option and input a FORMULA that will return the average for all itmes within each months period (when adding a column to the list ?
DATE ACCOPEN AVERAGE
01/01/2010 2 2
02/01/2010 2
03/01/2010 2
04/01/2010 2
01/02/2010 2 2
02/02/2010 2
03/02/2010 2
04/02/2010 2
You're not going to be able to do this OOTB without writing event receiver code (or other custom code running in a batch mode).
To get you started
MSDN - How to: Create an Event Handler Feature
Event Handlers : Everything you need to know...
This will need to hook into the list item update and then consolidate your list into a separate summary list with the calculations you need.
The brute force approach would be to run the calculation afresh for every item in the group when an item is inserted/updated.
A smarter approach would be to just update the delta (the difference between the old and the new record) which is easier to do if you store components of the calculation - so in your case
Month - NumRecords - TotalValue
and work out the Average on the fly (as its easy to delta the NumRecords/TotalValue but impossible to apply it directly to the average)
One 3rd party web part which may fit your need is PivotPoint - it allows you to do things like sum/count/avg over groups like Month & Year (disclaimer - I work for the company)
It is not possible to query anything other than the current item when creating a formula field.
The only way to do this is to create custom code either within an event handler for the list or external code that processes items in the list and updates a "average" field when required.
Create a calculated field to give you the year and month, for example: 2011-07. Then modify your list view to group on the calculated field. When editing your view, there is also an option to display totals, I believe you can set this to average for your AccOpen column. If you're not interested in the details, you can choose to collapse all groups by default.

Lookup value in column to display name

I've got 2 columns - Name ID and Name.
When a user adds a new entry to the sharepoint datasheet in the form, they have a dropdown list of all names (around 20 in total).
What can I do, so that when they select the name, the Name ID field auto-populates with its corresponding details?
Is there somewhere I need to hold this data and how do I go about creating these calculated columns?
Thanks in advance
You should just be able to do something like this
=TEXT([NameIDcolumn])
# Or
=CONCATENATE("You selected:", [NameIDColumn])
However, you cant use the value from the ID column or any think like that in a calculated col since the value does not exist yet. The SharePoint dev team was most likely smoking crack when creating that datatype since a lot of good stuff that should have been there isn't.
You have the complete reference of stuff you can make with calculated columns here http://office.microsoft.com/en-us/windows-sharepoint-services-help/CH010065006.aspx

Can I create a COUNTIF calculated column in SharePoint?

Is there a way to create a SharePoint calculated column that returns a count of the number of entries in a list? So If I have 3 customers in my list with the company "Starbucks" I'd like the field to return "3"
(Edited some wording for clarity per suggestion from dariom).
You may be able to get what you want with another list using a not-so-well-known variation of a lookup column.
Let's say you have a list called Companies with values in the title column like "Starbucks", "Peets", etc. Now you also have the Customers list you refer to, but the "Company" column is a lookup column pointing to the title column in the Companies list.
You can add a count very similar to what you described to your Companies list. Go to your Companies list, add a column of type "Lookup" referring to the Customers list and you'll notice that in the drop-down area where you define the lookup if you point back to the Customers list, you'll have a new option called "Count Related". This is here automatically because it recognizes that the Customers list has a lookup pointing back to this one. Select that Count Related option and now your Companies list will have a column counting how many customers are associated with that company.
No coding, Javascript hacks, or anything. Just hidden SharePoint auto-magic.
No, I don't think there's a way to do this using the out-of-the-box calculated column.
Some other ways you could accomplish this are:
Create a view for your list that with a group by on the company field and include the total count. This is easiest, but might not be exactly what you're looking for.
Create a custom column type that executes a CAML query to find items that you're interested in. There is a learning curve if you've not done it before and if the list that you're adding this custom column to has lots of rows, you'll be executing a query for each row which is inefficient - it'll be OK for a small number of rows.
Use an event handler on the list that updates a column value each time a new item is added or removed from a list. This is easier, but can also be inefficient if you have a large number of items in your list.
As dariom said (damn my slow typing skills, +1!), only the current row can be operated on with calculated columns by default in SharePoint. There are a couple of documented workarounds involving SharePoint Designer or jQuery, though.
You can get a Count of specific list items in an XSLT Data View
To do this you will need SharePoint Designer.
Right click on your SharePoint List view (ensure the list view contains the field you want to filter by) select convert to XSLT Data View. Then in the Data Source Windows select Data Source Tab and drag and drop the field you want to get a total on for the specific items into where you want it displayed in your XSLT Data View. Click on the numerical value that is showing you should get a lightening bolt icon, select the drop down and choose Count, then select again and choose Filter. Select "Click here to add a new clause" then choose your field name again and enter your unique value as Starbucks and click OK, you can repeat this process for other fields you want the totals on. You will now see the total number of Starbucks items in the list.
I got something similar to work in a way similar to Niall. Basically, I:
Based on the source list, created a Data View Web Part (DVWP) on a "test" web
part page.
Added the footer column, which gives a count.
Set the filter for my conditions (i.e., the items I want to count).
In the code, deleted the recurring items row.
I was left with just the footer, which displayed a filtered count for all the list items. I further customized the footer by taking out the shaded background. Finally, I exported this web part and imported it onto the page where I wanted users to see a total of items in the list (which met the criteria).

Resources