1,804 articles and 14,829 comments as of Wednesday, May 11th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint 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
Tuesday, May 5, 2009

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

Formulas for Testing Multiple Conditions

Overview

In the last series of articles discussing logical functions, we looked at nesting multiple “IF” statements together to test for each possible outcome in order to arrive at our final solution.

To model this approach, we looked at using common logic modeling tools like “Truth Tables” and “Hierarchical Flowcharts” to first build out the path the logic will take, then transform that logic into a complete formula we can simply paste into a SharePoint calculated column.

In this series, we’ll look at bringing in the additional logical functions of “OR” and “AND” in order to test for combinations of logical tests all within the same check.

Getting Started

 To begin, we first need to understand the logic associated with both new functions, so we’ll revisit our “Truth Table” in order to illustrate how each of these works.

Calculated Column Part 6 

The basics behind the “OR” function is that if any of the values are “TRUE”, the entire statement is “TRUE”, and if none of them are “TRUE”, the entire statement is “FALSE”.

We can use the “OR” function to test for up to 30 different values together and as long as at least one of them results in true, the end result will also be “TRUE”.

Next Steps: Adding in the Questions

 “People might not get all they work for in this world, but they must certainly work for all they get”. – Frederick Douglass

At a traditional business, in order for someone to receive a paycheck, there’s a minimum criteria that must be met…they should be in the system (meaning they’re an employee on record), and should have worked a number of hours.  Of course, there’s also the possibility that they took vacation days or sick leave as well, so we’ll look at these three types of “Hours” in order to see if they should be issued a paycheck.

Our conditions (questions) will be:

“Regular Hours”
“Vacation”
“Sick Leave”

Adding these into our “Truth Table”, it becomes:


Calculated Column Part 6

Looking at the logic of each row in the table:

Row 1: Employee worked “Regular Hours”, took “Vacation”, and submitted “Sick Leave”.  Since at least one of the three was true, the final “Result” is “TRUE”, so the employee will be issued a paycheck.

Row 2: Employee worked “Regular Hours”, took “Vacation”, but did not submit “Sick Leave”.  Again, since at least one of the three was true, the final “Result” is “TRUE”, so the employee will be issued a paycheck.

Rows 3-7: At least one of the three was true, so the final “Result” is “TRUE” which will allow for a paycheck to be issued to the employee.

Row 8: In all previous rows, at least one condition was true, the final result was “TRUE”, but in the last row none of the conditions have been met.  Since none of them result in true, the final “Result” is “FALSE”, so the employee will not be issued a paycheck.

Next time, we’ll look at the “AND” function and how it differs from the “OR”.

- 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

4 Responses to “Taming the Elusive “Calculated Column” – Logic – Part 6”
  1. Charlie Epes says:

    Hi Dessie:
    Another great, well explained article! Thanks-

    I guess this is exactly what I need to use, but I need advice. I need to test if 6 date fields are in the future (current) or in the past (expired). My purpose for using your testing is to eventually create an html color scheme with a percentage that indicates what percent of the 6 date fields are “current”. Sounds like a little Dessie mixed with some Christophe, yes?

    Thanks

    Charlie Epes
    Buffalo, NY
    [email protected]

  2. Charlie,
    Sounds kinda like you already have an idea of what to do :)

    Through JavaScript (jQuery would be better probably), you can compare dates listed (your 6 date fields) to the current date, then use that in addition to Christophe’s render-html script to work with your colors.

    If you post this as a question on the STP forums, I’ll bet Paul will jump in and help out.

    - Dessie

Trackbacks

Check out what others are saying about this post...
  1. [...] Taming the Elusive “Calculated Column” – Logic – Part 6 [...]

  2. [...] Taming the Elusive “Calculated Column” – Logic – Part 6 [...]




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!