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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Error for Query Builder database function

cmhaka
8-Gravel

Error for Query Builder database function

Hello,

I am calculating using Time Difference (days) how long an Activity has been open or was open before completion. I have nested it inside the Decode function in order to account for the 2 scenarios of Actual Finish being Null or populated with a completion date. The user is unable to accurately sort the result of the Decode because it handles it like a string and does not put them in chronological order. So I have nested the Decode inside the To Number function. This allows the numbers to be sorted properly. The numbers bring back along of decimal places so I wanted to restrict that to 2 decimal places and tried encasing the entire thing inside the Round function. When I add the Decode function inside the To Number function I get the error “Attributes of data type string are not valid for this function”. Does anyone know why that error would be produced? The To Number outside of the Decode functions correctly and sorts correctly as a number. But when I try the entire thing inside the Round is when I get an error.

 

This works correctly......

 

cmhaka_0-1709665876818.png

 

 

When I try to do the Round function as the outer function on all of the above, adding the Decode function below the To Number function is when the error pops up.

cmhaka_1-1709666006915.png

 

Thank you!

@cmhaka 

 

 

2 REPLIES 2
HelesicPetr
21-Topaz II
(To:cmhaka)

Hi @cmhaka 

If you use the round, don't you need to define a second variable what is the length?

HelesicPetr_1-1709712339203.png

HelesicPetr_0-1709712325574.png

I miss the length in your example.

PS> write the full error message

PetrH

Hello @HelesicPetr 

 

Thank you for your response. I apologize that my second screen print didn't show the entire intended outcome. Here is the intended solution and it is working now that I completed it.

 

cmhaka_0-1709738294414.png

 

But when I build it I receive the following error when I add the Decode line and when I add the Null line.

 

cmhaka_1-1709738349850.png

 

Yesterday I stopped at the error. But today I clicked OK on the error box and kept building to see if it would work. It is working despite the error boxes. So I am not sure why the error boxes are popping up.

 

cmhaka

 

 

 

 

Top Tags