Jump to content

How do I add the pre-defined "shift" variable to my piweb report?


---
 Share

Recommended Posts

Hello, I am trying to add in the "Shift" variable to my piweb report, but I am not finding it in the "variable" drop down lists in the piweb editor. Am i just blind and not seeing it? I have been searching around for a while now and am wondering if i have to type in the viariable "code" manually for it to show up which I am not sure how to do. I have multiple programs that use this variable so it would be great to add it into a report. I have already created a custom piweb report that doesnt have the "shift" variable, but now im making a different one and i cant seem to find it anywhere. Any help is appreciated, thank you!


image.png.76d50d2eec49a27e04d894150955df14.png

Link to comment
Share on other sites

been a long time since i set mine up, but it looks like my custom fields were in variable/data provider/reference measurement. Dont know if that will help you or notimage.png.9572272e09d2391fe8b98b8ff27f2ad4.png

  • Like! 1
Link to comment
Share on other sites

Please sign in to view this quote.

That worked thank you very much! How do you find the variables? I am also trying to do one for machine number, but it would be great to know how to find them out myself.

Link to comment
Share on other sites

Please sign in to view this quote.

If you have the bubble help option active, there's a column on the right side of the header selection window that will show you what's assigned when you hover the mouse over it. Was more clearly visible in older Calypso versions.

bhelp.JPG

variablepopup.JPG

  • Thank you! 1
Link to comment
Share on other sites

Please sign in to view this quote.

Thank you very much, i noticed that the one you posted has ",-1" added instead of what is shown in the image you sent. What does that mean?

Edited
added question
Link to comment
Share on other sites

Please sign in to view this quote.

I think that tells Piweb to fetch the recorded value from the most recent entry in the database. Most of the predefined stuff in the standard report uses that format as well.

  • Like! 1
Link to comment
Share on other sites

Please sign in to view this quote.

This was answered, but I can offer specifics. Imagine a list of numbers representing measured values: [1, 2, 3, 4, 5]. In most programming languages (that I am aware of), lists and other data structures are "zero indexed" meaning if you were to reference a value at a specific index, you start listing from 0. In my example, we would say that 1 is the 0th element, 2, is the first element, and so on. 

By using -1 as your index, you look at the value that is before the 0th index. If you think of the list as being cyclical, then it is easy to see that the index before the 0th will be the last element in the list which, for our purposes with PiWeb, is the most recent measurement. So for any place that you see a -1, you could replace it with whatever number you want and retrieve the value at that index. I am doubtful of the applicability of this in most cases, but the option does exist.

  • Like! 1
Link to comment
Share on other sites

Please sign in to view this quote.

Very interesting, does that mean if I was to instead use 3 instead of -1, it would always display "Night" due to it being the second one in the list? (in the photo i posted earlier in this topic) or would it recall the second time the variable was used? Or am i just misunderstanding lol.

Link to comment
Share on other sites

Please sign in to view this quote.

If it worked exactly as I've described (cyclically), choosing 3 for the index would return a value of "Day", since "Day" is the zeroth entry, "Night" is the first entry, and "Weekend" is the second entry. So following the logic, the "third" entry would be "Day".

However, it's not actually cyclical in that way. I described it that way because I think that makes seeing why -1 returns the final option easier but if it were implemented in this way, lots of things might break. For instance, if a new shift was added (call it "Weekend 2") suddenly, calling the third element of the list returns "Weekend 2" and not "Day".

What will happen if you select an index that doesn't exist is raise an error that goes more or less like "Index out of range", which just means there is no corresponding value for that index.

In general, for a list of length n you have 2n valid indices. One index counting up from 0 for each element in the list and one index counting down from -1 for each element in the list. 

  • Thank you! 1
Link to comment
Share on other sites

Please sign in to view this quote.

For "Measurement" categorized variables, the supplied argument (the second number in the sequence) dictates which recorded measurement the page will access and display. If you used 3, it would always display the shift value for the fourth measured part. -1 is usually what you want for stuff like this, since it accesses and displays the last (i.e. the most recent) measured value.

shift-tooltip.JPG

  • Thank you! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...