Child pages
  • Additional Custom Expression Examples
Skip to end of metadata
Go to start of metadata

Example: Indicate if a number is "Even", "Odd", and "Unknown".

Use a variable to record the set of numbers you wish to use. Then set variables to mark the points at which the number is considered odd or even. Finally, use two if (cond, trueValue, falseValue) blocks to return the "Odd", "Even" or "Unknown" text based on the number value.

n%2==0 shows if the number is divisible by 2 with no remainder. This is an "Even" number

 

 

n%2 !=0 shows if the number is divided by 2 does have a remainder than the number is "Odd"

n=[Average: WB1];
if( n%2==0,
 "Even",
 if (n% 2 != 0,
 "Odd",
 "Unknown"
 )
)

 

Example: Presidential Party Value Change.

case([Year],
1960, "R",
1961, "D",
1962, "D",
1963, "D",
1964, "D",
1965, "D",
1966, "D",
1967, "D",
1968, "D",
1969, "R",
1970, "R",
1971, "R",
1972, "R",
1973, "R",
1974, "R",
1975, "R",
1976, "R",
1977, "D",
1978, "D",
1979, "D",
1980, "D",
1981, "R",
1982, "R",
1983, "R",
1984, "R",
1985, "R",
1986, "R",
1987, "R",
1988, "R",
1989, "R",
1990, "R",
1991, "R",
1992, "R",
1993, "D",
1994, "D",
1995, "D",
1996, "D",
1997, "D",
1998, "D",
1999, "D",
2000, "D",
2001, "R",
2002, "R",
2003, "R",
2004, "R",
2005, "R",
2006, "R",
2007, "R",
2008, "R",
2009, "D",
2010, "D",
2011, "D",
2012, "D",
2013, "D",
2014, "D",
"Unknown: " + [Year]
)

 

Example: Presidential Value Change.

case([Year],
1960, "Dwight D Eisenhower",
1961, "John F Kennedy",
1962, "John F Kennedy",
1963, "John F Kennedy",
1964, "Lyndon B Johnson",
1965, "Lyndon B Johnson",
1966, "Lyndon B Johnson",
1967, "Lyndon B Johnson",
1968, "Lyndon B Johnson",
1969, "Richard Nixon",
1970, "Richard Nixon",
1971, "Richard Nixon",
1972, "Richard Nixon",
1973, "Richard Nixon",
1974, "Gerald Ford",
1975, "Gerald Ford",
1976, "Gerald Ford",
1977, "Jimmy Carter",
1978, "Jimmy Carter",
1979, "Jimmy Carter",
1980, "Jimmy Carter",
1981, "Ronald Reagan",
1982, "Ronald Reagan",
1983, "Ronald Reagan",
1984, "Ronald Reagan",
1985, "Ronald Reagan",
1986, "Ronald Reagan",
1987, "Ronald Reagan",
1988, "Ronald Reagan",
1989, "George H Bush",
1990, "George H Bush",
1991, "George H Bush",
1992, "George H Bush",
1993, "Bill Clinton",
1994, "Bill Clinton",
1995, "Bill Clinton",
1996, "Bill Clinton",
1997, "Bill Clinton",
1998, "Bill Clinton",
1999, "Bill Clinton",
2000, "Bill Clinton",
2001, "George W Bush",
2002, "George W Bush",
2003, "George W Bush",
2004, "George W Bush",
2005, "George W Bush",
2006, "George W Bush",
2007, "George W Bush",
2008, "George W Bush",
2009, "Barack Obama",
2010, "Barack Obama",
2011, "Barack Obama",
2012, "Barack Obama",
2013, "Barack Obama",
2014, "Barack Obama",
"Unknown: " + [Year]
)
  • No labels