I need to remove the "Gross Annual Average", "Net Annual Average" and "Representation" columns from the month columns (green square). And leave them only in the totals (blue square). I have already tried this solution in conjunction with display none https://www.flexmonster.com/question/how-to-hide-grand-total-for-specific-columns/, but it causes an error on the front-end. How can I remove the remaining white spaces? I believe my problem is because I need to also remove the headers above!
class ReportConfig {
height = 750;
constructor (store) {
const results = store.results.items;
const totalCompanyNetRevenue = store.results.totalCompanyNetRevenue;
const year = store.filter.fields.year.value;
const currentYear = dayjs().year();
const month = year == currentYear ? dayjs().month() : 12;
this.config = {
"dataSource": {
data: results,
type: 'json',
mapping: {
economicGroup: {
caption: 'Conta Agrupada',
type: "string",
},
customer: {
caption: 'Cliente',
type: "string",
},
project: {
caption: 'Projeto',
type: "string",
},
date: {
caption: 'Ano-Mês',
type: "date string",
format: "MMM yy",
},
},
},
slice: {
rows: [
{
uniqueName: "economicGroup",
},
{
uniqueName: "customer",
},
{
uniqueName: "project",
},
],
columns: [
{
uniqueName: "date",
},
{
uniqueName: "[Measures]",
},
],
measures: [
{
caption: 'Resultado Bruto (I)',
uniqueName: "grossTotal",
aggregation: "sum",
format: 'RealFormat',
},
{
caption: 'Resultado Líquido (II)',
uniqueName: "netTotal",
aggregation: "sum",
format: 'RealFormat',
},
{
caption: 'Média Anual Bruta',
formula: sum('grossTotal') /
${month},
uniqueName: "avgGrossTotal",
format: 'RealFormat',
},
{
caption: 'Média Anual Líquido',
htp.p('htp.p(''formula: sum(''''netTotal'''') / ${month},'' );'
);
uniqueName: "avgNetTotal",
format: 'RealFormat',
},
{
caption: 'Representatividade',
htp.p('htp.p(''formula: sum(''''netTotal'''') / ${totalCompanyNetRevenue},'' );');
uniqueName: "representativeness",
format: 'PercentFormat',
},
],
},
"formats": [
{
"name": "RealFormat",
"thousandsSeparator": ".",
"decimalSeparator": ",",
"decimalPlaces": 2,
"currencySymbol": "",
"currencySymbolAlign": "left",
nullValue: "0,00",
"textAlign": "right",
"isPercent": false
},
{
"name": "PercentFormat",
"decimalPlaces": 2,
"currencySymbolAlign": "left",
nullValue: "0,00",
"textAlign": "right",
"isPercent": true
}
],
options: {
showAggregationLabels: false,
grid: {
type: "compact",
},
},
};
this.customize = (cell, data) => {
const onlyInTotals = new Set(["avgGrossTotal","avgNetTotal", "representativeness"]);
if (data && data.measure && onlyInTotals.has(data.measure.uniqueName) && !data.isGrandTotalColumn) {
console.log(cell, data);
if (data.type === "value" || data.type === "header") {
cell.text = "";
}
}
};
}
}
Hope! Any support here?
Hello, Rodrigo!
Thank you for reaching out to us.
Flexmonster allows hiding specific measures in columns by setting their width to 0 inside the tableSizes
object. To do this, you should specify the necessary member tuple and measures that should be hidden:
tableSizes: {
columns: [
{
tuple: ["country.[Australia]"],
width: 0,
measure: {
uniqueName: "Quantity",
aggregation: "sum",
},
},
//Other columns
}
Additionally, we suggest combining this with hiding the numeric sheet headers with the showHeaders
grid option. This is recommended because hiding the columns does not change the column index, leading to inconsistent column numeration in headers.
We have prepared a JSFiddle illustrating this approach, where the "Quantity" measure is hidden from all columns except totals: https://jsfiddle.net/flexmonster/Ledwg0c8/
It is also possible to hide measures programmatically instead of manually defining the hidden measures in the report. To do this, implement a function that uses the getMembers method to get the necessary member tuples and changes the table sizes with the setTableSizes method.
Please let us know if this approach would work for you.
Best Regards,
Maksym
Thanks for the support. It worked for me.
Hello, Rodrigo!
Thank you for your reply.
We are glad to hear that the suggested solution worked for you.
Feel free to contact us if more questions arise.
Best Regards,
Maksym