Is there a way to pass a tagname as a string in a TimeXX function (within AF Analysis)?
Something like TimeGT("\\piservername\sinusoid",'*-1h','*', 20)
Thanks in advance,
I have found a workaround using your inputs. I have to use 2 analysis:
I cannot do both things in a single analysis. Don't worry, it is correct like that!
Here below what I have:
Thanks a lot for your support. Really appreciated!
To my knowledge this isn't currently possible. Out of curiosity why do you need the string input? I'm guessing you're input is variable ? We can create a user voice request for this, I'm just curious as to what the use case is.
Currently inputs are resolved when the analysis starts up, not at execution time. The data the analysis uses for calculation is fetched periodically before the execution time and available in the data cache. I believe this is why this isn't currently possible.
Thanks for your reply
In a perfect world, I will use variable/attribute as input. However, we are testing the migration of an application to AF and some expressions are currently written in a string format that I tried to parse within Analysis. So this is why I was interesting to that.
I have tried many things but I did not find a way to convert the "tagname" string into 'tagname' variable (single quotes). I know that this use case is not so current but it could help.
Anybody found a workaround for that or it is just impossible (natively)?
There may be hacks or tricks that exist. Here is a link to an old one:
But I haven't tested to see if that hack still exists.
And you are limited to Periodic scheduling because Event triggering requires a known attribute or tag be bound for any triggering to occur.
I get that you want to have flexibility in changing the name of an active tag, but truthfully how many possible tag names are you talking about? If you also want Event triggering, you would need to declare each possible tag in the analysis as potential input triggers. Then you could have logic to take the input name and match it to one of the declared tags.
I had already a look on your tricks before posting. However, it seems not working in my case (or I did not find how to do it).
As a complement, the string expression coming from the 3rd party application looks like "PITagName > Value" and it must be true over a period (so in Analysis, the TimeGt is the equivalent).
It could be any PI Tags from the PI Data Archive! So I have thousands of potential cases
The trick I posted still works for me using PI Server 2018 SP2.
When looking up by attribute name, I am mapped to SINUSOID. When looking up by PIPoint, I am mapped to CDT158.
This analysis cannot be Event triggered unless the input PIPoint is a string tag containing the name you are looking up.
I stand corrected Rick Davin, nice clever little trick using TagNum()!
FYI, this is a published workaround in the Analytics Tips & Tricks KB.See tip #6: https://customers.osisoft.com/s/knowledgearticle?knowledgeArticleUrl=KB01520
Or direct link: https://customers.osisoft.com/s/knowledgearticle?knowledgeArticleUrl=AF-Analytics-How-to-construct-an-attribute-referenc…
Thanks for sharing KB link Brent Bregenzer. Up to now, I have considered this hack undocumented and therefore subject to be eliminated without warning. Since it is indeed documented in the KB, I have peace of mind that this "feature" won't disappear.
Just a precision, the TagNum() works well when passing an attribute (in string format) but not with a tagname in string format. This is why we need to use an intermediate attribute in my case.
It could be an enhancement in a future version.
Retrieving data ...