cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Query builder decode function

Newbie

Query builder decode function

Does anyone know how to load and use the decode function in query builder? If so can someone provide me with a snippet of code of what it should look like.
2 REPLIES 2

Re: Query builder decode function

I just figured it out with a hit or miss approach.  It works just like a "CASE" statement in code.

Begin by adding (for example) in the select field a function, decode.  It will appear as a single node.

Click on the node, and click "Add".  This will make the node a folder tree, with a single node under it.  This first node is what you are looking for.

So, in my case, I wanted to know if the word "attach" was in the description of a work item, then decode it.  So, that first node mentioned above (the one that is added underneath the "DECODE" folder tree), I click on that, and again, made it a function, "In String".  following the same process, I added "Work Item.Description" from the attributes, then under that (adding a second node under the "In String" tree) a constant, "attach".  This means that the result, if the word "attach" is in the description, for me, was "11".  However you establish "what you are looking for" this should the first node / function tree beneath the "DECODE" node.

Then, add constants one after another beneath to define the cases, starting with case, then result.  So, beneath my "In String" node, I put a node, constant, "11" then a node, constant "Complete / Attach CSS" then another node, "0" (result from In String if attach is not found), then another node "Approve in CRB".  I'm not sure if one DECODE node can look for several different results, then compare, but if you can come up with an attribute, function, or other that will indicate for you on it's own, many different cases, then reference that first under the DECODE node, then add your cases beneath.  (ie:  0, "Chicago", 1, "New York", 2, "Los Angeles".

I've attached a screenshot.Decode.png

Re: Query builder decode function

Hi Robert,

I don't know if you are aware of this group Reporting and this document Resource for reporting I wrote.

It is open for contribution of all users.

I think you did an excellent illustration of how to use the decode function and maybe you can add a link to this discussion in the "Tip and tricks" section of my document or, if you agree, I'll do it for you.

Thanks

Marco
Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group