7 Replies Latest reply on Mar 7, 2019 10:02 AM by mannevt

    PI Analysis - Getting first 5 values greater than -1

    mannevt

      In Pi AF structure, I have 100 Attributes to be monitored and these have -1 as default value.

       

      Now In Analysis, what is the best way to figure out the first 5 attributes which has valid data(greater than -1) and map each of those to a corresponding Attribute

       

      for example say

       

      A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 ..........A100 are the attributes to monitor.

       

      suppose at some point of time I have below attribute values,

      A7 - 5

      A24 - 9

      A43 - 6

      A78 - 3

      A83 - 7

      A84 - 1

      A96 - 4

       

      Insuch case I should consider A7, A24, A43, A78, A83 and map them with attributes C1, C2, C3, C4, C5 and

       

      C1 should hold value as 'A7-5' where A7 is the attribute name and 5 is its corresponding value like wise,

      C2 should have A24 - 9

      C3 should have A43 - 6

      C4 should have A78 - 3

      C5 should have A83 - 7

       

      and at some other point it can be

       

      A17 - 52

      A21 - 74

      A48 - 37

      A64 - 45

      A76 - 8

      A78 - 23

      A82 - 56

      A94 - 12

       

      In this case I should consider A17, A21, A48, A64, A76 and map them with attributes C1, C2, C3, C4, C5

       

      C1 should have A17 - 52

      C2 should have A21 - 74

      C3 should have A48 - 37

      C4 should have A64 - 45

      C5 should have A76 - 8

       

      Any suggestions would be greatly appreciated.

        • Re: PI Analysis - Getting first 5 values greater than -1
          sraposo

          Hi Tarun,

           

          I don't think there is an easy way to do this with Asset Analytics. I need to think about this a little more. 

           

          Writing a custom AF SDK application or custom Data Reference for this type of problem shouldn't be too hard. Are you familiar with the AF SDK?

           

          Thanks ,

          Seb

            • Re: PI Analysis - Getting first 5 values greater than -1
              Rick Davin

              At the 2018 Innovation Hackathon, someone had a similar use case, except instead of Attributes they wanted Elements.  It's similar enough to talk about because both of you do not want to receive a primitive value, such as 9, but rather want the AFObject that currently contains that primitive value.  At the hackathon, the team was not skilled with AF SDK but did manage to get something working using Analytics.  But let's not sugarcoat this - it was a hack of a solution that was quite fragile in design, and would not scale very well.  This may work fine in a 23-hour hackathon, but is definitely something to avoid in a production system.

               

              Sebastien is on the right track.  This would be more easily done with a custom data reference.  Since you have posted this question in PI Developers Club, I have my fingers crossed that you are a developer and should not require more arm twisting to pursue a data reference solution.

            • Re: PI Analysis - Getting first 5 values greater than -1
              gregor

              Hello Tarun,

               

              Can you please describe your use case?

                • Re: PI Analysis - Getting first 5 values greater than -1
                  skwan

                  How often do you want to do this assessment?  I assume your 100 attributes (A's) would get new values over time.  Therefore, we need to define the criteria for when you need to do this assessment.  In addition, when you say the "first 5 attributes", how do you decide which is the top 5?  Is it the top 5 alphabetically?  Is it the top 5 based on what you see on your screen?  Do you expect a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 in that order or a1, a10, a2, a3, a4, a5, a6, a7, a8, a9 in that order?  For some systems, the ordering may or may not be the same.

                   

                  What's your use case?

                  --

                  Steve Kwan

                  1 of 1 people found this helpful
                    • Re: PI Analysis - Getting first 5 values greater than -1
                      mannevt

                      Stephen,

                       

                      In this case, I will have live data feed. So the analysis will run every time there is change in value for any of these 100 attributes.

                      And w.r.t attribute order it has nothing to do, it can be any order.

                        • Re: PI Analysis - Getting first 5 values greater than -1
                          skwan

                          Tarun,

                          Maybe I wasn't clear about my question so let me try asking again :-).  In your original question, you said you want the " the first 5 attributes which has valid data(greater than -1)".  Therefore, we need to determine what the first 5 attributes are, which is the reason why I asked about ordering.  Let's say you have valid data with 10 attributes, a1-a10 at a given time.  Do you expect the first 5 attributes to be: a1, a2, a3, a4 and a5 in that order or a1, a10, a2, a3 and a4 in that order or as you view them in something like PI System Explorer in which case you may have sorted the UI by some other parameter such as "Group by Category" which would make the ordering of the attributes different visually.

                          --

                          Steve Kwan