I tested a point array of number PI tags and run the following: "MapData('TestArray', IF BadVal($val) Then 1 Else 0)". The output array provided all zeros even when the last value in the array should have come up as bad or "1".
Issue is due to the data type of the array as it is considering the value of the digital state than digital state itself.
Below is an example how it is working.
PI Tag values:
Created a point array with single tag (just for demo) and same tag added as a separate attribute.
As array is single data type bad value (system digital state) is converted int value.
Test2PointArrayTag has latest value bad but Point Array shows MapData evaluates as good as it is considering digital state value i.e. 307 for bad.
MapData function with Recorded values.
RecordedData with MapData shows correct output value based on input values.
I have a feeling your expression is not actually evaluating the current value of each tag. If the array contains PI Point names this become rather tricky.I have used expression like the following to obtain the current value:
Mapdata('Tag array', TagVal(TagNum(Concat('serverName',$val))))
Once you have the current value, you then can use the BadVal check you currently are using. Note, the serverName attribute I used in in the format of "\\ServerName\".
Retrieving data ...