0% found this document useful (0 votes)
35 views

Mendix HowToDashboard

Uploaded by

Rahiyan Safin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Mendix HowToDashboard

Uploaded by

Rahiyan Safin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Dashboarding

How to build dashboards in Mendix


There’s two key types of dashboard…
Actionable & Reporting
Total Orders Payments taken ($) Delayed deliveries

105 1,337 59
Weekly average 100

Task list

An actionable dashboard is generally a landing page for a Reporting dashboards involve rolling up and analysing
user and the type you’re likely to build in Mendix. It should large groups of data. This is best accomplished with an
show them any current key data that may need attention external tool such as Power BI or Grafana. It also usually
and point them towards today’s actions or other common includes point-in-time or comparative reporting.
tasks.
Mendix dashboard samples…
Aggregating data…
If you’re creating a dashboard you’ll more than DashboardData
likely need some aggregated data. So let’s start with TotalOrders (integer)
PaymentValue (decimal)
a non-persistent entity… DelayedDel (integer)

Now you have a choice about HOW to aggregate that data:

Microflow Aggregate Tables OQL


The best choice is usually to use a microflow. The next best choice is to change your dataset to aggregate the
data as it goes where possible and still use a microflow. The final option for large sets of data or to aggregate
multiple groups of data in one go is to write an OQL query.
Microflow…
Your first option is to use a microflow as the data source for your dashboard. You can use retrieve actions to
gather the data and then list activities to aggregate it (with counts or sums for example).
When you do this Mendix will automatically optimise the query so the database will simple return the
aggregate value; so long as you don’t use the retrieve result again in the microflow!
This becomes less effective the more aggregates you wish to retrieve but works fine for most circumstances.

Optimised to single DB query

Take sum of Create


Retrieve list of
Attribute DashboardData
Order from
‘Value’ in (TotalValue)
database
OrderList $NewDashboardData
OrderList SumValue NewDashboardData DashboardData
List of Order Decimal DashboardData
Storing aggregated data…
When you are dealing with a high volume of data, or want to compare data across periods, then it’s sometimes best to maintain
aggregate tables. These tables can store Date/Time stamped, rolled up data which can then be used directly from the table.
There’s a couple of ways to do this. You can either update the tables as you create new records, or make changes, in the source data. Or
you can use scheduled tasks to run an aggregate function on a timer, maybe over night, to roll up the data.

DailyDashboard
SF_CreateOrder
TotalOrders (integer)
PaymentValue (decimal)
DelayedDel (integer)
DateStamp (DateTime)
MonthlyDashboard
TotalOrders (integer)
PaymentValue (decimal)
DelayedDel (integer)
SCH_Rollup_Dashboard_Data DateStamp (DateTime)
OQL
When aggregating large sets of data or multiple values you can use a query language called OQL. OQL is a lot like SQL but there are
some subtle difference, check out the OQL Guide for more info. It allows you to execute a single query and return multiple aggregated
values in one go. All you need is a non-persistent entity with matching attributes ready to receive the data.
To do this you’ll first need to visit the Marketplace and download the OQL Component. This will allow you to execute your OQL queries.

'SELECT COUNT(1) AS TotalOrders, SUM(PricePaid) AS PaymentValue FROM Store."Order“ WHERE


createdDate >= ''' + formatDateTime(addDays([%BeginOfCurrentDay%],-30),'yyyy-MM-dd') + '‘’'

Create String Execute OQL


Head
variable statement
$NewDashboardData
DashboardData
OQLQuery DashboardDataList NewDashboardData
String List of DashboardData DashboardData
Preparing chart data…
Mendix provides charts based on the Plotly library. You can grab
the Charts widget from the Marketplace or, if you want more
control, there’s the AnyChart option (see next page...) 1. Choose a chart type and drag it on
2. Add a Series to the chart
If you’re using a standard chart widget then you can quite easily 3. Leave your series as static and select an entity to
connect your data source to an aggregate microflow, like the one display
shown previously. Just drop a DataView onto your page (the 4. Choose a data source:
context isn’t important*) and then follow the steps to the right. 1. If you want to use a microflow choose microflow
and select or create an aggregation flow using the
techniques we’ve shown
2. If you want a direct query leave it as database and
AggregatedData enter some Xpath to filter your data if you wish
5. Next specify your data points then:
OrderCount (integer) 1. For microflows you’re done but note the data must
OrderDay (Date)
be sorted in the microflow
2. For a direct database query then set a sort
4 attribute and select how you’d like to aggregate
SF_Aggregate 3 duplicate data (Sum in our example) so when it
dOrders 2
1
finds data for matching X values it knows how to
AggregatedDataList 0 handle them
List of AggregatedData Mon Tue Wed Thu
Preparing AnyChart data…
To use AnyChart then the data should be provided in a JSON format.

We can do this by providing a JSON structure file and using an Export Mapping to convert our data retrieved from the
table. This can then be added to a non-persistent entity to serve up to the chart on your page.

** DON’T FORGET TO WRAP YOUR EXPORTED DATA IN SQUARE BRACKETS! **

JSON_Data_Over_Time It’s best to pass dates as


AggregatedData
Suggested format:
strings so they format
OrderCount (integer)
OrderDay (Date)
{ correctly
x: [‘DATE', ‘DATE’,’DATE'],
y: [1.0, 3.0, 6.0]
}

4
ChartData 3
SF_Aggregate
dOrders
JSON_Orders_By_Day 2
Data (string)
1
0
AggregatedDataList
Mon Tue Wed Thu
List of AggregatedData
Dashboard design tips… Different users may need different dashboards. Don’t be
afraid to create multiple dashboards!
Large KPI Values
These are great for highlighting
areas at a glance, through use of Time frame
dynamic colours, that may need Always make sure you state what
attention. Try not to have more
Last 7 days time frame the data on the
than 4 on a page. Total Orders Payments taken ($) Delayed deliveries dashboard covers. The time frame
427 2,012 48 should preferably be consistent
across the whole dashboard.
Avoid large blocks of data Weekly average 400
(Sometimes you might need
If you need to show a list of Task list unique sections though)
data, such as a task list or
pending orders, try and keep
the list short with only the key Pie, Donut, Heat map charts
information shown. The user These charts are often misused so
can then click through for use with caution. Avoid using
more info. them with large groups of data
or data that has very similar
ranges for each group.
Bar, line and column
• Great for comparing data groups
• Line charts should have no more than 5 lines
• Bar/Column charts should have no more than 8 bars This is just a few options. Mendix allows for almost unlimited
• If there’s no logical sort for the data (time for example) creativity through SASS, widgets on the Marketplace and your own
then try to sort biggest to smallest custom pluggable widgets!
Exposing data for a reporting dashboard…
When you want to do an external reporting dashboard the easiest way to accomplish this is to publish
your data as an OData source. You can then connect to this using Power BI, Grafana or Excel, and then
use your chosen software to slice up the data and display it how you want to.

It’s worth giving some consideration as to whether this is the right solution though. If you require
comparative reporting (one period vs another), point-in-time reporting, or to combine data from
multiple sources then it might be worth considering publishing your data to a Data Warehouse.

You might also like