mrc logo mrc logo
  • m-Power m-Power
    What is m-Power?
    Overview Demos Build Process Case Studies Specs Pricing Trial
    m-Power Resources
    Overview How-To Videos Webinars & Podcasts White Papers Fact Sheets
  • Solutions Solutions
    What does m-Power build?
    Overview Database Front-Ends Reporting CRM Systems Business Intelligence Dashboards Inventory Management Mobile Apps ERP Enhancements Modernization Spreadsheets to the web MS Access to the web B2B/Web Portals Scheduling Embedded Analytics Web Forms Workflow Data Exploration Budgeting & Forecasting APIs and Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Services Services
    Development Services Training Mentoring
  • About About
    Overview Partners Press Releases Careers Events Contact Blog
  • Support Support
    Support Home FAQ Documentation Customer Portal Enhancements Updates Roadmap Techblog
Try m-Power

m-Power Manual

Browse:

  • Home
  • Calculations
  • Conditional Calculations
Back to Manual

Conditional Calculations

 

Conditional Calculations are a great tool to be able to customize your application and take them to the next level.

Some examples of conditional calculations could be:

  1. To control the color of individual data. For instance, you could divide data output into three different color groups: red (for low performing values), yellow (for mid-range values), and green (for high performing values).
  2. To control what options are available to a user. For instance, you wish to show an Update link when a field is equal to a certain value. Otherwise, show an Add link.

Conditional calculations allow you to not only create calculations, but also incorporate them into your output via m-Painter.

Using Conditional Calculations to Control Color

For the first example, we will examine how to use conditional calculations to modify the color of your result set based on the value of a field. To do this, we will use calculations as we did before. First, we need to decide how we are going to categorize the data. In this example, we will look at Labor Cost and divide them into three groups (0, 0 through 5, and greater than 5). The calculations will be set up as such, so that each calc is equal to a CSS class name:

Build your application and enter the painter application. Click the source button as we will be adding some in-line style sheets. Copy this code just above the </head> tag:

<style type="text/css">
.lablow { font-family:Verdana,Arial; font-size:8pt; color:#FF0000; background-color:#FFFFFF; border:1px solid #003121; }
.labmed { font-family:Verdana,Arial; font-size:8pt; color:#FFFF00; background-color:#FFFFFF; border:1px solid #003121; }
.labhi { font-family:Verdana,Arial; font-size:8pt; color:#00FF00; background-color:#FFFFFF; border:1px solid #003121; }
</style>

Feel free to edit the above code as necessary. Above, all fonts are veranda, 8pt and share a background color of white. The difference is in the text color (lablow is red, labmed is yellow, and labhi is green).

Note: lablow, labhmed, and labhi listed in the style sheet relate back to the value of the calculation we created earlier.

The last step is to change the class name of your <td> tag to ${row.CALCULA001} so that when the application runs it will substitute CALCULA001 for the appropriate value (lablow, labmed, labhgh) and will then apply the appropriate inline style. Once done, your <td> tag should like like the following:

<td class="${row.CALCULA001?html}" align="left">

Using Conditional Calculations to Control Output

For the final example, let's assume we are trying to dictate what text shows depending on a value in a report. Specifically, let's say you are working with a report that sets budgets. If the budget has not been set (currently equals 0), you want the user to click a button that lets them add the record. However, if the value does not equal 0, you want users to be able to click a button that allows them to update the budget for that line. A basic approach would be to just display both links, but with conditional calculations, we can set the application up so it is "smart" enough to know what link to display.

In the Calculations screen, we will need to add two conditional calculations. What we will be doing is coding both hyperlinks into the application, but with the use of the CSS property "display", we will hide the hyperlink that is not applicable. To do this, set up your calculations as noted below:

The rationale for setting up the calculations as noted above is that if the budget is not set to zero, we want the user to be able to update the record. Otherwise, if it is zero, the user will only be able to see the option to add the record. Setting the CSS property display to none hides the element from the page so only one of the links will be shown. When we code in m-Painter, we will add this style and calculation to the appropriate link.

Compile your application and paint it so the two links are in the same column, as shown below:

As a reminder, your link to update a record should look similar to this:

LIBRARY.MXXXXXs?slnk=1&action_mode=UVK&FIELDNAME=${row.NAME}

While add mode should resemble this:

LIBRARY.MXXXXXs?slnk=1&action_mode=AVK&FIELDNAME=${row.NAME}

Once completed, right-click on the cell that contains these two links and select Cell » Edit Cell HTML. This will pull up the HTML for this cell, so we can add style="display:${row.CALCULA001?html};" to each link. Once completed, it should look like the screenshot below.

Notice how Calc 1 is applied to the "Update Record" link while Calc 2 is applied to the "Add Record" link.

Click OK and then save.

Run the app and your final result should look like this:

Note: The same structure listed above can be used to insert images as well as text. Simply use the calculation in the src value of the <img…> tag for the image you wish to use.

Created: February 29, 2008 | Modified: May 9, 2012

Search


Browse By Category

Build Process (13)
Starting with m-Power (8)
Retrievals (10)
Reports (15)
Summaries (4)
Maintainers (17)
Graphs (8)
m-Power Data Explorer (4)
General (24)
Calculations (5)
Utilities (9)
m-Power Administration (23)
Security (11)
Freemarker (6)
m-Painter (29)
Form Validation (5)
External Objects & UDFs (12)
Deprecated Documentation (23)
Bootstrap Templates (7)

Popular Tags

Popular Graphs Graph Properties Production Freemarker Admin m-Painter Prompt Screens Maintainers App Properties SQL Calculations Data Dictionary Bootstrap Templates Bar Graphs Video Record Selections Reports Excel Security Java Form Validation Tomcat Application Properties RPG External Objects Advanced Getting Started Dates mrc-Productivity Series Build Process Administration Retrievals Retrieval Database Compiling Maintainer Parameters Report Email DB2 Performance Graphing Summaries Dropdowns

See all tags »

michaels, ross & cole, ltd. (mrc)

Privacy Policy Cookie Policy Cookie Settings Notice at Collection Do Not Sell or Share My Personal Information

mrc (US)

2001 Midwest Road
Suite 310
Oak Brook, IL 60523
630-916-0662

mrc (UK)

Mortlake Business Centre
20 Mortlake High Street
London, SW14 8JN
+44-20-335-59566


© 2024 mrc. All rights reserved.