Ads

Showing posts with label Calculated Column. Show all posts
Showing posts with label Calculated Column. Show all posts

Friday, 17 February 2017

Few formulas for calculated column in SharePoint list

Conditional formulas
You can use the following formulas to test the condition of a statement and return a Yes or No value, to test an alternate value such as OK or Not OK, or to return a blank or dash to represent a null value.
Use the IF function to perform this comparison.
Formula Description
=[Column1]>[Column2] Is Column1 greater than Column2? (Yes)
IF([Column1]<=[Column2], "OK", "Not OK") Is Column1 less than or equal to Column2? (Not OK)
=AND([Column1]>[Column2], [Column1]<[Column3]) Is 15 greater than 9 and less than 8? (No)
=OR([Column1]>[Column2], [Column1]<[Column3]) Is 15 greater than 9 or less than 8? (Yes)
Date and time formulas
To add a number of days to a date, use the addition (+) operator.
Formula Description
=[Column1]+[Column2]
Example:
Column1=6/9/2007
Colimn2=3
Adds 3 days to 6/9/2007 (6/12/2007)
To add a number of months to a date, use the DATE, YEAR, MONTH and DAY functions.
Formula Description
=DATE(YEAR([Column1]),MONTH([Column1])+[Column2],DAY([Column1]))
Example:
Column1=6/9/2007
Colimn2=3
Adds 3 months to 6/9/2007 (9/9/2007)
To add a number of years to a date, use the DATE, YEAR, MONTH and DAY functions.
Formula Description
=DATE(YEAR([Column1])+[Column2],MONTH([Column1]),DAY([Column1]))Example:
Column1=6/9/2007
Colimn2=3
Adds 3 years to 6/9/2007 (6/9/2010)
Calculate the difference between two dates
Use the DATEDIF function to perform this calculation.
Formula Description
=DATEDIF([Column1], [Column2],"d")
Example:
Column1=01-Jan-1995
Colimn2=15-Jun-1999
Returns the number of days between the two dates (1626)
=DATEDIF([Column1], [Column2],"ym")
Example:
Column1=01-Jan-1995
Colimn2=15-Jun-1999
Returns the number of months between the dates, ignoring the year part (5)
=DATEDIF([Column1], [Column2],"yd")
Example:
Column1=01-Jan-1995
Colimn2=15-Jun-1999
Returns the number of days between the dates, ignoring the year part (165)
Calculate the difference between two times
Formula Description
=TEXT([Column2]-[Column1],"h:mm:ss")
Example:
Column1=06/09/2007 10:35 AM
Colimn2=06/09/2007 3:30 PM
Hours, minutes and seconds between two times (4:55:00)
Mathematical formulas
Add/Subtract and Multipyl/Divide the two column numbers.
Formula Description
=[Column1]+[Column2]+[Column3]
Example:
Column1=4
Colimn2=5
Column3=6
Adds the values in the first three columns (15)
=[Column1]-[Column2]
Example:
Column1=7
Column2=5
Subtracts 5 from7 (2)
=[Column1]*[Column2]
Example:
Column1=7
Column2=5
Multiplies the numbers in the first two columns
=[Column1]/[Column2]
Example:
Column1=15
Column2=5
Divides
Change the case of text.
Formula Description
=UPPER([Column1])
Example:
Column1=Gowtham RAJAMANICKAM
Changes text to uppercase (GOWTHAM RAJAMANICKAM)
=LOWER([Column1])
Example:
Column1=Gowtham RAJAMANICKAM
Changes text to uppercase (gowtham rajamanickam)
Combine first and last names
Formula Description
==[Column1]&[Column2]
Example:
Column1=Gowtham
Column2= RAJAMANICKAM
Combines the two strings (GOWTHAM RAJAMANICKAM)
Notes

  • Calculated columns can only interact with data in the same “item” such as an item is a single task, event, document and so on
  • Calculated columns cannot interact with another row, or summaries (total and so on) of all of the lists
  • The formulas you write are basically Excel compatible formulas
  • Calculated columns can be reused by creating them as Site Columns (but this column can only reference other Site Columns!)
  • Column names with spaces or symbols must be enclosed in brackets “[Sale Amount']”
  • The [TODAY] and [ME] functions do not work in a calculated column, but can be used in columns referenced by a calculated column 
Refer Here: One,


Wednesday, 23 April 2014

IF statements for calculated columns in SharePoint 2010 Lists

Here are some examples of IF statements that can be used in calculated columns.
The IF statement is simply:
IF(condition, ifTrue, ifFalse)
Compare text value:
Scenario: If field1 equals Yes we want to display Approved otherwise display Rejected.
Formula:
=IF([field1]="Yes","Approved","Rejected")
2 conditions must be true using AND:
Scenario: If field1 and field2 both equal Yes then display Approved otherwise display Rejected.
Formula:
=IF(AND([field1]="Yes",[field2]="Yes"),"Approved","Rejected")
Either condition can be true:
Scenario: If field1 OR field2 equal Yes then display Approved otherwise display Rejected.
Formula:
=IF(OR([field1]="Yes",[field2]="Yes"),"Approved","Rejected")
Check if field is blank:
Scenario: If field1 is blank display Approved otherwise display Rejected.
Formula:
=IF(ISBLANK([field1]),"Approved","Rejected")
Compare number column values:
Scenario: If field1 is less than 1 Approved otherwise display Rejected.
Formula:

=IF([field1]<1,"Approved","Rejected")

Thursday, 4 April 2013

SharePoint calculated column and jQuery Highlight row

Lets discuss, What you can do by SharePoint calculated column and jQuery here is small practical stuff follow the instructions and do it yourself you will surely enjoy this work I am sure.

Sometimes you need to represent SharePoint List in terms of legend like in map. Say for example you have result list and you want to show those Student who got less than 35% marks Should Have “Red” Legend, those who got 100% marks with “Blue” Legend , those who got >65% with “Pink” Legend , those who got >70% with Yellow, marks > 60 with Green.

Follow the steps
1. Create Result SharePoint custom list.


2. Create column StudentName single line text.

3. Create Column Color with Calculated Column.


Copy and Paste following code in formula.
=IF((Marks*100)>=100,"#0000FF",IF((Marks*100)>=70,"#FFFF00",IF((Marks*100)>60,"#FF00FF",IF((Marks*100)>=35,"#00FF00","#FF0000"))))

4. Create another column called Display.


Copy and paste following formula
="<DIV style='border: 1px "&Color&" solid;background-color:"&Color&";color:#FFFFFF;'>"&Marks*100&"<DIV>"

5. Now your fields looks like this


6. Open new form and Add Student Name and Marks obtained by him.
7. Once you enter marks for student your SharePoint list looks like this


8. Edit Page

9. Add ContentEditor webpart.

10. Add Following Code in Source Editor
<script type="text/javascript">
if(typeof jQuery=="undefined"){
var jQPath="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/";
document.write("<script src='",jQPath,"jquery.min.js' type='text/javascript'><\/script>");
}
</script>

<script type="text/javascript">


$(document).ready(function(){
$(".ms-vb2:contains('<DIV')").each(function(){
var tempDIV = document.createElement ("DIV");
tempDIV.style.cursor = "pointer";
tempDIV.innerHTML = $(this).text();
$(this).text("");
$(this).append(tempDIV);

});
});
</script>

11. Click ok button
12. Now your result SharePoint list look like


you can also do many more things using jQuery and Calculated column.

Saturday, 16 March 2013

Setting default Time with Date in date time column

We can set default date to current date but not time using date time field.
By below trick we can also achieve that

Create New column of Data and Time type --> select Date and Time under Format,
select Calculated value radio button and enter the following:
=Today+"01:30 PM".

 This will set the default time to default current date.

Ads