Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a column that needs to return the value of another column based on if the value in a third column = S

share|improve this question

2 Answers 2

You simply need to use IF statements: http://msdn.microsoft.com/en-us/library/bb862071.aspx

For example:

=IF([Column1]<=[Column2], "OK", "Not OK")
share|improve this answer
    
What I'm trying to do is this: –  Richard Kinkead Mar 4 '13 at 21:31
    
if column 4 = "S" then column 6 value if not then "0" –  Richard Kinkead Mar 4 '13 at 21:32
    
In excel I would write it: –  Richard Kinkead Mar 4 '13 at 21:33
    
=IF(A4="S",A6,"0") –  Richard Kinkead Mar 4 '13 at 21:34
    
It works the same way Excel formulas do. For example: =IF([Column1]="S", [Column2], ""). –  John Chapman Mar 4 '13 at 21:37

In addition to John's answer which seems best,

You can attach a Item Adding event to your list or you may able to use calculated columns.

Here's the code to give you an idea,

public override void ItemAdding(SPItemEventProperties properties)
{
    try
    {
        string newFieldValue = GetNewFieldValue();
        object oldFieldValue = properties.AfterProperties[COLUMN_NAME];
        if (oldFieldValue == null || oldFieldValue.ToString() != newFieldValue)
        {
            properties.AfterProperties[COLUMN_NAME] = newFieldValue;
        }
    }
    catch
    {
        //Log the error, or take another appropriate action.
    }
    finally
    {
        base.ItemAdding(properties);
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.