I wanted to post this in case someone else was bringing in weather data and ran into this issue - TBH I struggled with figuring this one out for a while in vision.
Scenario: Operators want weather data brought into PI so they can trend it against plant performance - our process is heavily affected by wind speed. Only issue is that my plant doesn't believe in using true north as their north - north to the operators is our nearest industrial neighbor (Plant A), which is approximately 40 degrees off true north.
Solution: I used powershell and PI UFL to bring in our weather data from darksky (posted over here: Darksky weather access using Powershell and UFL) and stored the info in pi tags.
Since our compass circle is 40 degrees towards the west relative to true north, our compass goes from -40 to 320 degrees vs 0 to 360. I implemented the following code in AF, set for natural evaluation off the wind direction tag coming in from darksky to correct the direction:
IF (PrevVal('True North Wind Direction','*')-40)<0 Then (PrevVal('True North Wind Direction','*')+320) Else PrevVal('True North Wind Direction','*')-40
Then I implemented the awesome pi vision compass gauge symbol that Kenji Hashimoto created over here: PI Vision 2017 Compass Gauge symbol into PI vision and linked it to the corrected AF attribute, giving the attached display