1,804 articles and 14,423 comments as of Sunday, January 2nd, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint (Joel Oleson) content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Wednesday, May 13, 2009

Taming the Elusive “Calculated Column” – Logic – Part 10

Our Final List

In SharePoint create a list called “Employee Paychecks”.

Calculated Column Part 10

Create a column called “Employee”, make it a “Choice” type and add in the two choices of “Yes” and “No” as “Radio Buttons”. 

Calculated Column Part 10

NOTE – I chose the “Choice” column rather than the “Yes/No” checkbox option because the “Yes/No” type doesn’t have a clear display as to what it really is (it doesn’t actually display the text “Yes” or “No” and can be confusing).  Using a “Choice” type instead, will clearly display just what the column is for and will make it more readable for the users.

Create three additional columns for the 3 types of hours all in the same fashion as the “Employee” column (“Choice” type, “Yes” “No” choices, “Radio Buttons”).

Column titles: “Regular Hours”, “Vacation”, “Sick Leave

Calculated Column Part 10

Since we’re using “Choice” columns in our list, we’ll need to add in a little bit more to our formula in order to test for the values that they’ll be returning.

Formula so far:

=IF(AND([Employee], OR([Regular Hours],[Vacation],[Sick Leave])),"Issue Paycheck","Do Not Issue Paycheck")

Change to:

=IF(AND([Employee]="Yes",OR([Regular Hours]="Yes",[Vacation]="Yes",[Sick Leave]="Yes")),"Issue Paycheck","Do Not Issue Paycheck")

This will allow us to check the return “text” value of each column to see if it’s either “Yes” or “No”.

Create our final column called “Issue Paycheck” make it a “Calculated” type with a return type of “Text” and enter in the modified formula.

=IF(AND([Employee]="Yes",OR([Regular Hours]="Yes",[Vacation]="Yes",[Sick Leave]="Yes")),"Issue Paycheck","Do Not Issue Paycheck")

Calculated Column Part 10

Once you have all columns created, enter in a series of items on the list using the same combinations of values from the “Truth Table”.

Calculated Column Part 10

NOTE – I’ve also added in a couple extra items to show that it will handle empty values as well (since empty does not equal “Yes”, the result will be false).

Conclusion

If we had taken the same direction as in the previous series (detailing the “IF”) to test for each possible combination of values with multiple nested “IF” functions, the formula would have been considerable longer, and would have worked, but would have been much less efficient. 

By using the “OR” and “AND” functions to test for combinations of values at the same time, we’ve not only lessened the development time need to create the formula, we’ve also made debugging and testing much easier (always a good thing).

Also, for those that may be wondering why we didn’t just use a single “Choice” column to house each of the options for hours, the reason is because SharePoint cannot handle “Multiple Select” values.  Since there isn’t an “Array” function to deal with dynamic data types (those that aren’t consistent in length), a calculated column will not be able to reference a column that (can) return more than a single value.  We could use a single Choice column, but it would defeat the logic we’re trying to accomplish since the calculation wouldn’t be able to see “more than one” choice…it would only see one.

Till next time…

- Dessie

Dessie LunsfordDessie Lunsford
Points-of-Sharing

View all entries in this series: Dessie Lunsford-Logic Formulas»
Entries in this series:
  1. Taming the Elusive "Calculated Column"
  2. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Task List
  3. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part II)
  4. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part III)
  5. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part IV)
  6. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Text and Data
  7. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part I)
  8. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part II-I)
  9. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-II)
  10. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-III)
  11. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part III)
  12. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part IV)
  13. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part V)
  14. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part VI)
  15. Taming the Elusive “Calculated Column” – Lookup and Reference
  16. Taming the Elusive “Calculated Column” - Logic
  17. Taming the Elusive “Calculated Column” - Logic - Part 1
  18. Taming the Elusive “Calculated Column” - Logic - Part 2
  19. Taming the Elusive “Calculated Column” - Logic - Part 3
  20. Taming the Elusive “Calculated Column” - Logic - Part 4
  21. Taming the Elusive “Calculated Column” - Logic - Part 5
  22. Taming the Elusive “Calculated Column” - Logic - Part 7
  23. Taming the Elusive “Calculated Column” - Logic - Part 6
  24. Taming the Elusive “Calculated Column” - Logic - Part 8
  25. Taming the Elusive “Calculated Column” - Logic - Part 9
  26. Taming the Elusive “Calculated Column” - Logic - Part 10
  27. Taming the Elusive “Calculated Column” - Date and Time - Part 1
  28. Taming the Elusive “Calculated Column” - Date and Time - Part 2
  29. Taming the Elusive “Calculated Column” - Date and Time - Part 3
  30. Taming the Elusive “Calculated Column” - Date and Time - Part 4
  31. Taming the Elusive “Calculated Column” - Referencing Multiple Lines of Text Column
  32. Taming the Elusive “Calculated Column” – Date and Time – Part 5
  33. Taming the Elusive “Calculated Column” – Date and Time – Part 6
  34. Taming the Elusive “Calculated Column” – Date and Time – Part 7
  35. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 1
  36. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 2
  37. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 3
 

Please Join the Discussion

6 Responses to “Taming the Elusive “Calculated Column” – Logic – Part 10”
  1. Himani says:

    Hi,

    I have a multiple choice column. However I wish to use its selected values as concatenated text in another calculated column. Since neither lookups, nor multiple choice columns are allowed in calculated fields. How do I achive it? Please help!!!
    1/ get concatenated text of all the selected choices.
    2) use this concatenated text in a calculated column to appear alongside another column (as concatenated string)

  2. Himani,
    Actually, you can use a choice column without problems as long as its a dropdown or radiobutton list. The only time it wont be available to use in a calulation is if its set for “checkbox” (multiple responses).
    The reason why is because a calculated column can only reference data that has a consistant or “single” possible result.
    Once you introduce the possibility of more than one answer for a field, you cant use it in a calculated column.

    With that being said, all you’d need to do is grab the value from the choice column and concatenate it with your other value using standard formulas.

    - Dessie

  3. Sanjay says:

    How do i count the number of times the list has been viewed by the user.

  4. Iain Munro says:

    Hi Dessie

    Merry Xmas and Happy New Year to you.

    I have noticed that the Stump the Panel is no longer in use.

    One thing I was looking for that I thought was there, was the formula you did for calculating the days between two fields while taking into account the weekends.

    Do you still have this formula kicking around?

    Iain

  5. Iain,
    Happy holidays back at ya!!

    STP is currently being worked on by Mark, and should hopefully be back soon.

    I’ll dig around and see if I have that formula still (I should) and post it here for you.

    - Dessie

  6. Robert G. says:

    Dessie,

    Thanks for these posts they have been a great help. I’m wondering if the following can be done. I have about 100+ products in a drop down list. Whenever one of those products is picked I would like a value to populate in the calculated field, is that possible given the amount of choices in the drop down box?

    For example If(drug=”a”,”renal”,if(drug=”b”,”bio”)) so on and so forth for 100+ products?

    Thanks in advance to any insight you can provide.

    Robert.\


Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!