Typically, a general report consists of:
select * from assets;
A SQL script which retrieves the data from DB. It may include all SQLITE defined operations.
The Lua script may implement these APIs:
function handle_record(record)
-- Your logic to modify a record and apply this function against every record from SQL.
record:set("extra_value", record::get("VALUE") * 2);
end
function complete(result)
-- Put some accumulated value and apply this function after SQL completes.
result:set("TOTAL", 1000);
end
The HTML template formats the output. It may contain Javascript and CSS for advanced formatting and processing.
A default template can be automatically generated and later modified. See below.
Call General Report Manager (GRM) tool or use main menu Tools → General Report Manager… .
Either a report is created from scratch or an existing report is imported and adapted.
There are a lot of reports provided by users or developers on GitHub.
MMEX provides the possibility to use report parameters in the SQL script, which are set with widgets and evaluated during the report generation.
These parameters are available:
| Parameter | Description | Widget |
|---|---|---|
| "&single_date" | A calender widget | ![]() |
| "&begin_date" and "&end_date" | A date range widget | ![]() |
| "&only_years" | A year selection drop down | ![]() |
| "&single_time" | A time widget | ![]() |
| "&stock_selection" | A list of stock names | ![]() |
| "&filter" | A generic text field for filter or similar conditions, together with a reset button (see description below) | ![]() |
| "&selection" | A generic selection list widget (see example below), which shows a list of predefined values | ![]() |
Notes:
For example, this SQL script returns all accounts balances for the specified date using a &single_date:
with
b as (
select
ACCOUNTID,
STATUS,
(case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1
where
STATUS <> 'V'
and TRANSDATE <= '&single_date'
union all
select
TOACCOUNTID,
STATUS,
TOTRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
TRANSCODE = 'Transfer'
and STATUS <> 'V'
and TRANSDATE <= '&single_date'
)
select
a.ACCOUNTNAME,
a.ACCOUNTTYPE,
total(TRANSAMOUNT) + a.INITIALBAL as Balance
from
ACCOUNTLIST_V1 as a
left join b on a.ACCOUNTID=b.ACCOUNTID
where
a.STATUS = 'Open'
and a.ACCOUNTTYPE !='Investment'
group by
a.ACCOUNTNAME
order by
a.ACCOUNTNAME asc;
Explanation:
With the filter widget an arbitrary value can be provided for the SQL processing.
with
var as (
select
-- Filter defined as as variable
'&filter' AS ACC_FILTER -- <= NEW
-- Single Date is defined here as variable:
'&single_date' AS MAX_DATE,
),
b as (
select
ACCOUNTID,
STATUS,
(case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
union all
select
TOACCOUNTID,
STATUS,
TOTRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
TRANSCODE = 'Transfer'
and STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
)
select
a.ACCOUNTNAME,
a.ACCOUNTTYPE,
total(TRANSAMOUNT) + a.INITIALBAL as Balance
from
ACCOUNTLIST_V1 as a
left join b on a.ACCOUNTID=b.ACCOUNTID,
var
where
a.STATUS = 'Open'
and a.ACCOUNTTYPE !='Investment'
and a.ACCOUNTNAME like var.ACC_FILTER -- <= Filter variable is applied here
group by
a.ACCOUNTNAME
order by
a.ACCOUNTNAME asc;
Explanation:

Notes:
With the help of filter options the name of the filter and a default value can be set. The options are provided as a SQLITE comment in the SQL script with following syntax:
-- &filter?name="any value"&default="any value"
Extending the previous example to name the filter "Account:"
--
-- Optional Filter name definition:
-- '&filter?name="Account:"
with
var as (
select
'&single_date' AS MAX_DATE,
'&filter' AS ACC_FILTER
:
will create the filter widget:
If the filter should be used without place holders, it is possible to modify the behavior in SQL:
--
-- Optional Filter name definition:
-- '&filter?name="Account:
with
var as (
select
'&single_date' AS MAX_DATE,
Case
WHEN '&filter' = '' THEN '%'
WHEN substr('&filter', -1) = '%' THEN '&filter'
ELSE
'&filter' || '%'
END
as A_FILTER
),
b as (
select
ACCOUNTID,
STATUS,
(case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
union all
select
TOACCOUNTID,
STATUS,
TOTRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
TRANSCODE = 'Transfer'
and STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
)
select
a.ACCOUNTNAME,
a.ACCOUNTTYPE,
total(TRANSAMOUNT) + a.INITIALBAL as Balance
from
ACCOUNTLIST_V1 as a
left join b on a.ACCOUNTID=b.ACCOUNTID,
var
where
a.STATUS = 'Open'
and a.ACCOUNTTYPE !='Investment'
and a.ACCOUNTNAME like var.ACC_FILTER
group by
a.ACCOUNTNAME
order by
a.ACCOUNTNAME asc;
Here the placeholder will be automatically added during SQL processing, therefore just by entering the first letters the matching accounts will be selected.
will create the filter output:
With the &selection widget a predefined set of values is provided for SQL processing.
The selections values are defined as SQLITE comment, together with an optional name and default, using following syntax:
-- &selection?values=[value],[value2],[value3],...&name=[name]&default=[default value]
The values list is mandatory, otherwise the selection widget will be displayed as an empty list.
The name and default parameters are optional.
--
-- Selection value definition (required):
-- '&selection?name="Status:"&values="Open","Closed","All"&default="All"
--
-- Optional Filter name definition:
-- '&filter?name="Account:"
--
with
var as (
select
'&single_date' AS MAX_DATE,
-- Filter Widget for account name:
Case
WHEN '&filter' = '' THEN '%'
WHEN substr('&filter', -1) = '%' THEN '&filter'
ELSE
'&filter' || '%'
END
as A_FILTER,
-- Selection Widget for State:
Case
WHEN '&selection' = 'All' THEN '%'
ELSE
'&selection'
END
as A_SELECTION
),
b as (
select
ACCOUNTID,
STATUS,
(case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
union all
select
TOACCOUNTID,
STATUS,
TOTRANSAMOUNT,
TRANSDATE
from
CHECKINGACCOUNT_V1,
var
where
TRANSCODE = 'Transfer'
and STATUS <> 'V'
and TRANSDATE <= var.MAX_DATE
)
select
a.ACCOUNTNAME,
a.ACCOUNTTYPE,
total(TRANSAMOUNT) + a.INITIALBAL as Balance,
a.STATUS
from
ACCOUNTLIST_V1 as a
left join b on a.ACCOUNTID=b.ACCOUNTID,
var
where
a.STATUS like var.A_SELECTION -- <= The selection statement!!
and a.ACCOUNTTYPE !='Investment'
and a.ACCOUNTNAME like var.A_FILTER
group by
a.ACCOUNTNAME
order by
a.ACCOUNTNAME asc;
Explanation:

If you have created any helpful report it may be exported into ZIP file.