I’m using a custom data reference (SQLServer) in PI AF to query forecasted volume data from our SQL database and write the results to an attribute. The query returns one data point per month, spanning from the start of the current month to 18 months out. Here's an example of the format returned in PI AF:
2025-04-01 12:00:00AM 1000m3
2025-05-01 12:00:00AM 1000m3
The custom data reference works as I expect and need it to. The issue comes in PI Vision when it loses functionality. In PI AF the value will output '1000m3' but in PI Vision it shows 'No Data'. Furthermore, when you hit 'Trend' or 'Time Series Data' in PI AF, it will display the data.
I believe the issue in PI Vision stems from the fact that it is essentially trying to look at the value "right now". But since there are only values at 2025-04-01 12:00:00AM and 2025-05-01 12:00:00AM it causes a "No Data" error. My solution to this was to change the timeframe in PI Vision from 8h to 1mo to include the period at which there is a data point. However, this results in the same "No Data" error.
My next train of thought was to create an analysis of this custom data reference attribute. It's purpose is to just write the attribute to a PI Point at a set interval, say every day. This works upon first glance, and when I "evaluate" in the Analyses tab it outputs the 1000m3 value. But when I go to the PI Point it returns "Calc Failed" as the value and states "System Digital State" as the status. I suppose this makes sense since it is running into the same issue as PI Vision, it is trying to find the value "right now" but there is only data at 2025-04-01 12:00:00AM and 2025-05-01 12:00:00AM, so it gets "No Data", resulting in "Calc Failed".
After this I decided I would just backfill the data so that the 2025-05-01 12:00:00AM value of 1000m3 could be read for "right now" and it could start outputting the value to the PI Point. However, when I go to backfill, I get the error: "Error(s) in retrieving data for input attributes. [Attribute]: Login failed for user [usercredentials]". This is strange because I am an admin and the [usercredentials] it uses do not match my account [mfitzowich]. This then creates a new issue which involves DBAs and SQL server access, etc. Something that I suppose could be fixed to resolve this issue, but I would rather keep the solution native to PI AF or PI Vision.
I am wondering if anyone has any experience with custom data references (SQLServer) that uses a SQL query to write to an attribute?
I am also wondering if this is just a current issue and if once the custom data reference reads the 2025-06-01 12:00:00AM on June 1, 2025 the Analysis I made will have data to read and ultimately write to a PI Point.
Attached are screenshots of:
-Error in PI Vision
-'Time Series Data' in PI AF
-Equivalent SQL query output in database
Here is my custom data reference (I have used generic names in some places to retain sensitive information).
DataTable:[schema].[table]; ValueColumn:[BudgetVolume]; TimestampColumn:[TransactionDate]; Server:[server_name] Database:[database_name]; WhereClause:[Scenario] = 'base' AND [AS_LocationCode]='Facility' AND [Category] = 'volume' AND [Account] = 'account#'; SourceTimeZone:[Mountain Standard Time]; ExpectedDataType:[Double]; IntegratedSecurity:[SSPI]; ConnectionTimeout:[10];
One final note: PI AF’s expression limitations make it difficult to filter this SQL data further without modifying the source. I’d prefer to keep all processing within PI rather than create new SQL views if at all possible.
Any insight would be helpful.