We will modify our principal data set to practice each of the following points. We will create a subreport, and within it we will create and configure two sparklines.
customer_id
at the end of the list of fields in the SELECT
statement. Our query should look like the following:SELECT country.country_id, country.country, customer.first_name,customer.last_name, SUM(payment.amount) sum_amount, payment.customer_id FROM payment INNER JOIN customer ON customer.customer_id=payment.customer_id INNER JOIN address ON address.address_id=customer.address_id INNER JOIN city ON city.city_id=address.city_id INNER JOIN country ON country.country_id=city.country_id WHERE country.country_id IN (20,24,29,34,48,67,74) GROUP BY payment.customer_id ORDER BY country.country, customer.first_name
In the Details section, beside the label Trend, we place a subreport object. Now we begin to work on the subreport.
Here we add an Import Parameter and configure it as follows:
customer_id
importCustomerId
sakila db
LastDateAmount
SELECT
YEAR(payment.payment_date) AS payment_year, MONTH(payment.payment_date) AS payment_month, SUM(payment.amount) AS sum_amount
FROM payment
WHERE payment.customer_id = ${importCustomerId}
GROUP BY 1, 2
ORDER BY 1, 2 DESC
LIMIT 0,3
Next, we click on OK to continue.
=MULTIVALUEQUERY("LastDateAmount";"sum_amount")
What the MULTIVALUEQUERY
function does in this case is it receives as its first parameter the name of the data set that we are going to work with, and as its second parameter, the name of the field in the data set that we will use. What the MULTIVALUEQUERY
function will do is create a string with the values of sum_amount
separated by commas. For example, the field sum-amount
in the Subreport's data set, for the customer CURTIS
, IRBY
from the country Canada
will return three rows as shown in the following screenshot:
So, in this case, after applying the MULTIVALUEQUERY
function, we get the following:
Attributes.value receives numerical data separated by commas. The technique suggested in the preceding section can be used for this purpose or some other, for example, using the group_concat
function in SQL, or by a PDI transformation, and so on.
4
#cc9329
=MULTIVALUEQUERY("LastDateAmount";"sum_amount")
4
#cc9329
The two sparklines we added to our report have the same data, but this way we can see more clearly the way each one represents information.
If we preview, we will see the following screenshot:
We added the field customer_id
to our report's principal data set in order to work with this field later. In the Details section, we added a subreport and configured it to import the value of the field customer_id
. We also created a data set for the subreport and added two sparklines to the Report Header section. First we configured the bar sparkline and then the line sparkline. Finally, we explained the MULTIVALUEQUERY
function.
We propose that you make a copy of the report we just created and modify it so it looks like the following:
What you should do is create a pie sparkline, place it in the Details Section, and configure it so it shows the portion of the pie corresponding to the current Amount.
The steps you should follow, broadly speaking, are as follows:
15_Adding_Hyperlinks_Sparklines.prpt
and save it with the name 16_Adding_Hyperlinks_Sparklines_Plus.prpt
.sum_amount
, and configure it as follows.=[sum_amount]/[TotalAmount]
0.15
0.25
#cf4646
#2ead03
Q1. State whether the following statements are true or false.