Recently we experienced some problems collecting data through the PI-Datalink (Some values were simply not available, all though they were available in Pi System Explorer).
This ment a lot of confusing and hassle until we got this exelent advice from OSISoft support:
Just enable and/or run the job "OSIsoft AF Maintenance (PIFD)", pressent in your SQL-Server containing the AF-Database. This rebuild indexes, update the cache, etc. The succes was immeadiate and we got good data in PI-Datalink again.
The job has been running every week and the "bug" has stayed away since.
For some peculiary reason, OSISOft does not enable the job bey default.