We want to be able to set decimals per row and not just globally. i.e we have row numbers we want rounded and other rows must have a decimal point. Is this possible ?
Hello, Andrew!
Thank you for reaching out to us.
It is possible to set different number formatting for every measure and its aggregation.
Keeping this in mind, if the measures are located in slice.rows
, you can create different formats for each measure, for example:
slice: {
rows: [
{
uniqueName:"[Measures]"
}
],
measures: [
{
uniqueName: "Price",
format: "TwoDecimals"
},
{
uniqueName: "Quantity",
format: "Rounded"
}
]
},
formats: [
{
name: "TwoDecimals",
decimalPlaces: 2
},
{
name: "Rounded",
decimalPlaces: 0
}
]
We have prepared a JSFiddle example for illustration: https://jsfiddle.net/flexmonster/myaxrtv3/.
You can find more details about number formatting in our docs: https://www.flexmonster.com/doc/number-formatting/.
Please let us know if the suggested approach works for your case.
Regards,
Solomiia
Hello, Andrew!
Hope you are doing well.
Our team is wondering if you had some time to check out our previous example.
Could you please let us know if it works for your case?
Looking forward to hearing from you.
Regards,
Solomiia
It does not work for us
var report = { dataSource: { data: data, }, rows: [{ uniqueName: 'description', }], measures: [{ uniqueName: "KP GP %", format: "decimal" }], columns: [{ uniqueName: 'description', caption: 'Description', }, { uniqueName: 'p1', caption: 'P1-Apr', }, { uniqueName: 'p2', caption: 'P2-May', }, { uniqueName: 'p3', caption: 'P3-Jun', }, { uniqueName: 'p4', caption: 'P4-Jul', }, { uniqueName: 'p5', caption: 'P5-Aug', }, { uniqueName: 'p6', caption: 'P6-Sept', }, { uniqueName: 'p7', caption: 'P7-Oct', }, { uniqueName: 'p8', caption: 'P8-Nov', }, { uniqueName: 'p9', caption: 'P9-Dec', }, { uniqueName: 'p10', caption: 'P10-Jan', }, { uniqueName: 'p11', caption: 'P11-Feb', }, { uniqueName: 'p12', caption: 'P12-Mar', }, { uniqueName: 'total', caption: 'Total', }, ]}, options: { validateFormulas: false, configuratorButton: false, chart: { type: 'stacked_column', position: 'top', showLegend: false, position: 'bottom', drillThrough: false, readOnly: true, activeMeasure: 'Total', }, grid: { type: 'flat', showFilter: false, showGrandTotals: 'rows', showReportFiltersArea: false, showHeaders: true, }, }, tableSizes: { "columns": tempWidthColumn }, formats: [{ name: '', thousandsSeparator: ',', decimalSeparator: '.', decimalPlaces: 0, maxSymbols: 20, currencySymbol: '', currencySymbolAlign: 'left', nullValue: ' ', infinityValue: 'Infinity', divideByZeroValue: 'Infinity', }, { name: 'decimal', thousandsSeparator: ',', decimalSeparator: '.', decimalPlaces: 1, maxSymbols: 20, currencySymbol: '$', currencySymbolAlign: 'left', nullValue: ' ', infinityValue: 'Infinity', divideByZeroValue: 'Infinity', }, ], }; this.report.setReport(report); }
Hello, Andrew!
Thank you for the provided code snippet.
We kindly ask you to provide us with the following information so we'll be able to continue the investigation:
We have also created a JSFiddle from your snipped: https://jsfiddle.net/flexmonster/bc2qo3rw/.
Please look through some changes we have added to the provided code:
1. We added the slice
property to the reportObject
:
report: {
slice: {
rows: [...],
columns: [...],
measures: [...]
}
}
2. In the flat view, all fields are located in columns, so we removed the duplicated "description" field from rows.
3. Regarding this.report.setReport(report)
command, please note that the report itself is a JavaScript object with value properties in it, and it doesn't contain any methods. We should call setReport()
from the Flexmonster instance instead:
var pivot = new Flexmonster(...);
pivot.setReport(report);
4. We also added the example for the tableSizes
property:
tableSizes: {
columns: [{
idx: 0,
width: 200
}]
},
Hope you will find our answer helpful.
Looking forward to your response.
Regards,
Solomiia
Hello!
Hope you are doing well.
Our team is wondering if you had a chance to look through our previous answer.
Could you please provide us with mentioned details of the use case to continue the investigation?
Looking forward to hearing from you.
Regards,
Solomiia