We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Can you support configuring number Format/Scaling in the pivot grid?

Answered
Yosef asked on June 14, 2022

We would like to be able to format values with scaling / units, such as 1000s.

For example: 1,000,000 => 1,000.

I wrote a customizeCell() function to do this, however we also need the user to be able to configure it and ideally save it to your JSON report config.

customizeCell(cell, data) {
if (data.type === "value" && data.value) {
const unit = 1000;
const format = flexmonster.getFormat();

let currencySymbol = format.currencySymbol;
if (!currencySymbol)
currencySymbol = ' $';

const delimitTest = delimitString(100, "");
const roundedUnit = round(data.value / unit, format.decimalPlaces);
const unitValue = delimitString(roundedUnit, "");
cell.text = currencySymbol + unitValue;
}

function round(number, decimalPlaces) {
const h = +('1'.padEnd(decimalPlaces + 1, '0')) // 10 or 100 or 1000 or etc
return Math.round(number * h) / h
}

function delimitString(str, delimiter) {
return str.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter);
}
}

Do you support this somewhere, or would be not too difficult for you to add it to the Format Cells options?

Alternatively can Flexmonster pick up number formats defined in Measures from Analysis Services (it doesn't seem to be)?

12 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 14, 2022

Hello, Yosef!
 
Thank you for contacting us.
 
Kindly note that Flexmonster doesn't support formatting values with scaling/units out of the box. Also, there is the known limitation that the customizeCell function cannot be saved to the report. Could you please let us know how critical the scaling/units feature is for you?
 
As for Analysis Services number formats, Flexmonster provides such an option too. You need to enable the useOLAPFormatting property to get already defined number formats from the OLAP cube.
Please note that Flexmonster's formatting will be ignored when using formatting from the cube.
 
You can find more details about this option in our docs: https://www.flexmonster.com/doc/number-formatting/#fromcube.
 
Looking forward to your response.
 
Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 21, 2022

Hello, Yosef!

Hope you are having a great week.

Our team is wondering if you had a chance to try the suggested useOLAPFormatting to get already defined number formats from the cube. Could you please let us know if enabling the OLAP formatting works for your case?

Looking forward to hearing from you.

Regards,
Solomiia

Public
Yosef June 23, 2022

Hi Solomiia,
Thanks for your response.
useOLAPFormatting looks really good but I can't see how to enable it in the UI. I suppose we could set it in the report JSON in the code behind. Is there a UI setting for this?
I will try and test it and let you know the result.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 23, 2022

Hello, Yosef!
 
Thank you for your question. 
 
Kindly note that useOlapFormatting option should be added to the report in the code as follows:

"report":{
 "options": {
      "useOlapFormatting": true
    }
}

To apply the option for all reports that could be opened through the UI, specify the options property in the globalObject instead of the report:

container: ...,
global: {
    options: {
      useOlapFormatting: true
    }
},
report: {
      ...
}

You can test this property in our JSFiddle, where the useOLAPformatting option is already enabled for all reports: https://jsfiddle.net/flexmonster/bgofd0am/.
 
If you want your end-users to switch to the OLAP number formatting via UI, you can use the setOptions() API call.
Here is a JSFiddle example for visualization: https://jsfiddle.net/flexmonster/932nkgfm/.
 
We hope it helps.
Looking forward to hearing from you.
 
Regards,
Solomiia

Public
Yosef June 27, 2022

Hi Solomiia,
Thanks for demos. I got it working for one column however if we have a percentage sum column on the formatted columns the percentages get skewed. 
What could be happening?

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 27, 2022

Hello, Yosef!
 
Thank you for your response.
 
We have managed to reproduce the described inconsistency in calculations of percentofcolumn aggregation used along with useOlapFormatting option. 
Our development team will take a look at this behavior and provide you with a fix, ETA Jul 11.
 
Kindly note that Flexmonster has a list of built-in front-end aggregations, which are calculated on the client side. This means that the number formatting from the cube could not be applied to them even with the fixed calculations.
 
You can find the full list of mentioned aggregations in our docs: https://www.flexmonster.com/doc/support-more-aggregations/.
 
Feel free to ask in case of any other questions.
 
Regards,
Solomiia

Public
Yosef June 28, 2022

Thanks Solomiia for letting me know and I'll wait to hear then.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 28, 2022

Hello, Yosef!

Thank you for your swift response.

Our team will notify you when the fix is ready.

You are welcome to ask if any further questions arise.

Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 11, 2022

Hello, Yosef!

Hope you are doing well.

We are glad to announce that the issue with internal aggregations when setting useOlapFormatting: true was fixed. 
This fix is provided in the 2.9.29 version of Flexmonster: https://www.flexmonster.com/release-notes/version-2-9-29/.

You are welcome to update the component. Here is our updating guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/.

Please let us know if the fix works fine for you.

Best regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 19, 2022

Hello, Yosef!

Hope you are having a great week.

Our team is wondering if you had some time to test the fix with internal aggregations using along with useOlapFormatting enabled. Could you please let us know if it works for you?

Looking forward to hearing from you.

Regards,
Solomiia

Public
Yosef July 19, 2022

Hi Solomiia,
Thank you for the fix it works great. 
Warm regards,
Yosef

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 20, 2022

Hello, Yosef!

Thank you for your feedback.

We are glad to hear that the fix works fine for you.

You are welcome to contact us in case of any other questions.

Best regards,
Solomiia

Please login or Register to Submit Answer