Hi,
I didn't find any proper information related to CHECKBOX calculate individual fields in Calculated fields.
Please provide relevant explanation with an example.
Regards,
Ravi
Hi Ravi,
Thank you for posting your question.
You can find more info on individual
property on our Calculated values documentation page – here it is explained that the individual
property defines whether the formula is calculated using raw or aggregated values.
For instance, the sum('Price') * sum('Amount')
formula is calculated differently depending on whether the "calculate individual values" option is selected:
individual: true
: 174 * 36 + 225 * 44
individual: false
: (174 + 225) * (36 + 44)
Feel free to check out an example illustrating this: https://jsfiddle.net/flexmonster/7mtwxqow/
Please let us know if this helps.
Best regards,
Mykhailo
Hi Mykhailo,
Thanks for the quick response.
Now I understand the individual property functionality.
But we need to enable that individual property by default to TRUE, is there any possibility to set by default? Or to hide that option itself instead setting default value?
Please provide any solution if exists.
Regards,
Ravi
Hi Ravi,
To enable calculating individual values for a field, simply specify the corresponding property in the report:
report: {
...
slice: {
...
measures: [
{
uniqueName: "Overall price",
formula: "sum('Price') * sum('Amount')",
individual: true,
},
...
]
}
}
This approach is illustrated in the sample mentioned in our previous response.
We hope this helps.
Regards,
Mykhailo
Hi Mykhailo,
Thank you for the quick response.
We're not adding calculated measure from CODING side, but adding from UI. Please check the attachment, in that we need to check the checkbox by default and needs to be disable for not to uncheck that. Otherwise provide any alternative to remove that entire functionality.
Regards,
Ravi
Hi Ravi,
Thank you for further specifying the desired behavior.
Please see the following sample we've prepared to illustrate how this behavior can be achieved: https://jsfiddle.net/flexmonster/3azokLnj/
In the sample, the following CSS configuration is used to hide the individual values checkbox from the calculated value pop-up altogether:
.fm-calculated-view > div > div > a.fm-ui-checkbox {
display: none !important;
}
Apart from that, the reportchange
event is used to track changes to the report (calculating value addition included) – every time it is triggered, each measure's individual
value is set to true
:
pivot.on('reportchange', function() {
pivot.off('reportchange')
let newReport = pivot.getReport();
newReport.slice.measures.forEach(measure => {
if (measure.formula) {
measure.individual = true;
measure.active = true;
}
});
pivot.setReport(newReport);
});
This ensures that all the calculated measures have individual
set to true
by default without the user having the ability to change that.
Please let us know if this helps.
Kind regards,
Mykhailo
Hi Mykhailo,
Thanks for the response.
I think 2nd scenario will not applicable for our requirement, will proceed with 1st one.
Regards,
Ravi