Expand my Community achievements bar.

Looking for code in a view that will prevent any value of 0 from being displayed

Avatar

Level 2
Looking for code in a view that will prevent any value of 0 from being displayed
Topics

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

7 Replies

Avatar

Level 7
So I'm guessing your scenario is you're displaying a number field, and if the value = 0, you don't want to display anything. Go to text mode and replace your "valuefield" statement with a valueexpression statement. If it's a field like Actual Cost (non-custom), your expression would be this: valueexpression=IF({actualCost}=0,"",{actualCost}) If this field is a custom field, your expression would look like this: valueexpression=IF({DE:fieldname}=0,"",{DE:fieldname})

Avatar

Level 2
Hi Greg, Thanks for your timely response! I'm sure your solution works, but I'm not implementing it properly. Here's my current code: displayname=Est Variance linkedname=direct namekey=Est Variance querysort=actualWork shortview=true textmode=true valueexpression=CONCAT(ROUND((SUB({actualWorkRequired},{workRequired}))/({workRequired})*100),"%") valuefield=actualWorkRequired valueformat=compound viewalias=actualworkrequired It's a field that compares actual hours with planned hours; if a task was planned to be complete in 10 hours, but it ended up taking 15 hours, the field shows +50% to indicate that the task took 50% longer to complete. If the value is 0% (actual hours = planned hours), we want the field to be blank. I'm sure the IF statement would solve this issue, but my attempts to implement it are not working. Could you show me how to edit my code? Also, I happened to notice that Michelle Yard just posted a similar question in the Global Forum, so she might be interested in the solution as well.

Avatar

Level 7
Replace your valueexpression with this: valueexpression=IF(SUB({actualWorkRequired},{workRequired})=0,"",CONCAT(ROUND(SUB({actualWorkRequired},{workRequired})/{workRequired}*100),"%"))

Avatar

Level 2
Thanks Greg - that's great, it works! What if I wanted to add an additional value? For instance, any value of -100 should likewise be excluded (which would indicate that the task has not yet been started, or hours logged)? Also, I'd like to make the positive values red, and the negative values green - how would I accomplish that in code?

Avatar

Level 7
For additional values you could do nested IF statements like in Excel (or you might be able to use an OR command like in EXCEL - I just don't know if it accepts "OR" or not.. As far as color is concerned, that's beyond my capabilities, but I've seen posts in this community site regarding that so I'm sure someone can post an update.

Avatar

Level 10
I concur, Greg: I'd use nested IF's. There is no OR that I'm aware of within a calculation (although there is an IFIN; but I don't think it would be appropriate in this case). For the definitive list of such goodies, check out https://support.workfront.com/hc/en-us/articles/217196767-Understanding-Calculated-Data-Expressions. As for the conditional formatting, Bill, I invite you to read this article as a primer https://support.workfront.com/hc/en-us/articles/217195897-Using-Conditional-Formatting-in-Views Regards, Doug

Avatar

Level 2
Thank you both - this has been a huge help - I'll check out the links, and happy New Years!