Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calculated field sharepoint based on 2 fields

Posted on 2014-12-13
5
Medium Priority
?
109 Views
Last Modified: 2014-12-20
Hello,

I need to create a status if an list item is ready for invoicing.


I need a calculated field (field3) with the following characteristics

If field1 has a value then field3 should be 0
if field2 = "Cancelled" then field3 should be 0
If field1 has no value then field3 should be 1

so calculated field3 should be either 0 or 1

thanks!
0
Comment
Question by:Hans de Jongh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 

Author Comment

by:Hans de Jongh
ID: 40498109
oeps sorry :)
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 1000 total points
ID: 40498435
Oeps, what? Why Powershell? Why Excel?

You can create an IF statement following syntax similar to Excel.

=if(isblank(field1),1,if(or(field2="cancelled,not(isblank(field1))),0,"something else"))

cheers, teylyn
0
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 1000 total points
ID: 40498807
Using powershell to update the field3 value based on the values of field1 and field2:

Replace the listname in the code:

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
 
#Variables that we are going to use for list editing
$webURL = <a href="http://portal.contoso.com">http://portal.contoso.com</a>
$listName = "Demo List"
 
#Get the SPWeb object and save it to a variable
$web = Get-SPWeb $webURL
 
#Get the SPList object to retrieve the "Demo List"
$list = $web.Lists[$listName]

#Get all items in this list and save them to a variable
$items = $list.items
 
#Go through all items
foreach($item in $items)
{
if(   ($item["field1"] -ne $null) -or ($item["field2"] -eq "Cancelled" ))
{
$item["field3"] = 0
}
else
{
$item["field3"] = 1
}
 
#Update the item
$item.Update()
}

Open in new window

0
 

Author Closing Comment

by:Hans de Jongh
ID: 40510870
thanks both, my question was not clear enough thats why i split the points..
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question