Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Negative IF ELSE statements v positive ones. List a specific task in a project report. (working code included)

Avatar

Level 10

I've noticed some folks prefer to use "not true" IF statements when creating list type columns as opposed to listing the results if true.

Is there some benefit to this or is it just preference? Here's are examples of listing a specific task in a project report:

Not True Statement:

displayname=Task Name Not True

listdelimiter=<div>

listmethod=nested(tasks).lists

textmode=true

type=iterate

valueexpression=IF({name}!="Task Name","",CONCAT({name}," | ",{assignedTo}.{name}," ",{plannedCompletionDate}))

valueformat=HTML

width=200

True Statement:

displayname=Task Name True

listdelimiter=<div>

listmethod=nested(tasks).lists

textmode=true

type=iterate

valueexpression=IF({name}="Task Name",CONCAT({name}," | ",{assignedTo}.{name}," ",{plannedCompletionDate},""))

valueformat=HTML

width=200

As you can see the first statement does nothing if the name=Task Name is NOT true, else it lists lists the task, assignee, due date.

The second example lists the task, assignee, due date if the name=Task Name IS true, else it does nothing.

I see more of the NOT true types in examples and posts than the TRUE one.

Does anyone prefer one over the other? and why?

I bet @Anthony Imgrund‚ and @Doug Den Hoed‚ have an opinion!

Either way, this an example of code some folks might find useful!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Level 10

Hi - I'll be 100% honest, I have never used !=. If I want "does not equal", I just switch the true and false sections of the IF statement.

Avatar

Level 10

Thanks Anthony,

I agree. I prefer the IF TRUE statements in most cases, much less confusing. I just wanted to know if there was some reasoning I was missing.

Avatar

Level 10

I don't use the shorthand (!=) mostly for clarity. Someone less math- or programming-nerdy may need to look at what I did and not know about the symbology. 😁

I'll use IF TRUE or IF FALSE variants depending on:

  1. Does testing for true or false arrive at the result faster or in a preferred order?
  2. Which way reads better if I was reading it back to myself. In other words, some things get approached as "if this were true" and some as "if this were false" (because sometimes a false result is the "positive" result).

It's difficult to explain; after doing various forms of programming in various languages, script systems, etc. I just do what feels right, more efficient, more readable, whatever.

Avatar

Level 6

My brain works much the same. 'How can I write this so when I'm trying to figure out how to modify it 6 months from now it still reads as plain language where my intent was common?'

I'm curious if there's a way to modify this so it brings back all tasks under a certain parent task. I hesitate to match on task names since I can't guarantee people won't change them.