Reporting Plug in conversion question

On a page I have a reporting screen in FPMI so I am hoping I am posting this in the right section. Anyway the dataset that populates this reporting screen comes from a query. The one section of the query brings in a value related to production time. However this value is in Seconds. I know the math on how to convert this value to Hours, Min, and Sec but am unsure exact how to incorporate this so it can be displayed properly on the reporting screen.

hours = floor(prodtime/3600)
min = floor(floor(prodtime/3600)/60)
sec = prodtime - ((hours * 3600) + (min * 60))

So this can take the data and convert it to the required numbers. But how would i then take this and set it up so that on the report it would show 2hr 27min 15sec?

I can get the report to show the hr min and sec titles but the substitution and conversion area has me a bit confused.

Thanks and have a great day.

You have 3 options:

  1. break them apart in the SQL query into three fields (hr, min, sec)
  2. feed the input dataset through a script that does the calculation and creates a new dataset which is fed to the report
  3. do it in the reporting plugin’s expression language.

Take your pick.

Could you point me in the right direction? Where do I find the information about using expression language in the reporting plug in? How far back does the expression language go? I am not running the most current version of the reporting plug in I am actually about 3 or 4 generations back. Have not update the PMI and reporting plug in yet.

Thanks and have a great day.

[quote=“Carl.Gould”]You have 3 options:

  1. break them apart in the SQL query into three fields (hr, min, sec)
  2. feed the input dataset through a script that does the calculation and creates a new dataset which is fed to the report
  3. do it in the reporting plugin’s expression language.

Take your pick.[/quote]

The manual would be a good bet. inductiveautomation.com/prod ... nkeys2.htm

Its always been there.

Ok I have been looking over the manual and unless I missed it there is one question that I did not see spelled out.

When you type in an expression is there a limit to the number of characters that are available?

The other question is if I do the math say in two seperate expressions something like:

@floor(totaltime/3600)@ hr @((floor(totaltime/3600))*60)- (floor(totaltime/60)@ min 

Is there a way to say take the first expression and have it equal some variable so as you dont have to retype the expression. As an example say you take and make H = to the first equation then in the second instead of typing the expression over again you would say H*60 - (........

Is this possible or would it be better to retype the expression?

Thanks and have a great weekend and a happy halloween.

The manual would be a good bet. inductiveautomation.com/prod ... nkeys2.htm

Its always been there.[/quote]

Martin,
In most cases you’ll have an easier time manipulating the Dynamic properties prior to pulling them into the reporting plugin (which supports as many variables of different data types as you need). You need to make a distinction with the type of data.

  1. For single data points you have the most power with FactoryPMIs expression language. This can be used to calculate/format/manipulate data coming from an SQL query, SQLTag, or object on the screen. This could be things like: report start/end date, very complex summaries (most can be done easily within the Reporting plugin), or any other data that applies to the report as a whole. Your reference here is the FactoryPMI expression language help.

  2. For dataSets, I would do most of the complex work in your SQL query prior to feeding the data into the Reporting Plugin. You can “pull out” the hour/minute/second as separate “columns” with the AS clause either manually doing the math as your example illustrates, or with SQL date/time functions. This is the best place for: string formatting, scaling, rounding, concatenating columns, etc. The notable exception here is for running totals, which is something that should be done in the Reporting Plugin at runtime.

  3. Finally, the Reporting Plugin can do the final manipulation on your data. It’s particularly good at aggregate functions (sums, count, min, max, etc) and data grouping. It works a little differently than the FactoryPMI designer in concepts like substitution keys, and it’s expression operators and functions are slightly different. The Reporting Plugin is pretty intuitive - just realize that it’s different than the FPMI Designer and fill gaps by reading the included documentation.

Nope

Yes, it is possible. See the assignment operator in the expressions portion of the manual. It is probably more trouble than its worth in your case, however. It is really meant to be use for multi-row calculations (like running sums), not for expression convenience.