How can I format the values in first column? (not measure columns)

Answered
Angel Hernandez asked on December 19, 2021

I'm trying to configure the following code in order to format the PROFIT column (which is the first one) as a currency.
Here you have a JSFiddle with the code below which is not working in a snippet:
https://jsfiddle.net/tlg265/eo1bkjwy/
Right now the values in that column are getting shown as:

1243898
1538192
1921982

But I want them to get shown as:

$1,243,898
$1,538,192
$1,921,982

Here you have a preview...
enter image description here
And below is the code, where you can see I introduced a new format: currency which I tried to use for that first column: PROFIT, but had no success.

$(function() {
  let pivot = new Flexmonster({
    container: "pivot-container",
    componentFolder: "https://cdn.flexmonster.com/",
    toolbar: false,
    report: {
      data: [{
          "Profit": "1243898",
          "Following": 81,
          "Followers": 242,
        },
        {
          "Profit": "1538192",
          "Following": 728,
          "Followers": 2178,
        },
        {
          "Profit": "1921982",
          "Following": 4423,
          "Followers": 12387,
        },
        {
          "Profit": "1243898",
          "Following": 63,
          "Followers": 189,
        },
        {
          "Profit": "1538192",
          "Following": 342,
          "Followers": 931,
        },
        {
          "Profit": "1538192",
          "Following": 487,
          "Followers": 1242,
        },
        {
          "Profit": "1921982",
          "Following": 3827,
          "Followers": 15281,
        },
        {
          "Profit": "1243898",
          "Following": 97,
          "Followers": 279,
        },
        {
          "Profit": "1538192",
          "Following": 242,
          "Followers": 728,
        },
        {
          "Profit": "1921982",
          "Following": 4921,
          "Followers": 12489,
        },
        {
          "Profit": "1243898",
          "Following": 69,
          "Followers": 182,
        },
      ],
      formats: [{
          name: "",
          thousandsSeparator: " ",
          decimalSeparator: ".",
          decimalPlaces: -1,
          maxDecimalPlaces: -1,
          maxSymbols: 20,
          currencySymbol: "",
          negativeCurrencyFormat: "-$1",
          positiveCurrencyFormat: "$1",
          isPercent: "false",
          nullValue: "",
          infinityValue: "Infinity",
          divideByZeroValue: "Infinity",
          textAlign: "right",
          beautifyFloatingPoint: true,
        },
        {
          name: "currency",
          currencySymbol: "$",
        },
      ],
      slice: {
        rows: [{
          uniqueName: "Profit",
          format: "currency",
        }],
        columns: [{
          uniqueName: "[Measures]",
        }],
        measures: [{
            uniqueName: "Following",
          },
          {
            uniqueName: "Followers",
          },
        ],
      },
    },
  });
});

Do you have any idea on how can I make this to work?

4 answers

Public
Angel Hernandez December 19, 2021

Please, bear in mind that on my real code the info comes through a CSV file referenced as:

report.dataSource.filename

 Thanks!

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 20, 2021

Hello, Angel,
 
Thank you for contacting us.
 
Currently, Flexmonster allows applying the formatting only to the measures. We can suggest you customizeCell API call, as a workaround. More information you can find in our documentation: https://www.flexmonster.com/api/customizecell/
 
Please let us know if such an approach would work for your case. Looking forward to your response.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 28, 2021

Hello, Angel,
 
Hope you are doing well.
 
We were wondering if you had a chance to try the suggested approach. Could you please let us know if our response helped?
 
Looking forward to your response.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster January 4, 2022

Hello, Angel,
 
Hope you are doing well.
 
Just checking in to ask if you found the suggested approach helpful. 
 
We will be glad to hear your feedback.
 
Kind regards,
Nadia

Please login or Register to Submit Answer