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

Using setFormat() on measure with multi-level hierarchy

Answered
Darius Studdard asked on March 3, 2022

Hi,
I'm trying to use the setFormat() API to change the display format of particular measures.  If you look at the attached screenshot you'll see that we have a measure called "Expected" which is underneath "Fact Claim".  I've tried using "pivot.setFormat(formatCurrency, "Expected", "sum");" and "pivot.setFormat(formatCurrency, "Fact Claim.Expected", "sum");" to change the formatting of this measure but neither seems to work.  I've tried it with and without the aggregation parameter.  
My formatCurrency object looks like this:
var formatCurrency = {
name: "currency",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2,
maxDecimalPlaces: 2,
maxSymbols: 20,
negativeNumberFormat: "-1",
currencySymbol: "$",
negativeCurrencyFormat: "-$1",
positiveCurrencyFormat: "$1",
isPercent: false,
nullValue: "",
infinityValue: "Infinity",
divideByZeroValue: "Infinity",
textAlign: "right",
beautifyFloatingPoint: true
};
 
I've seen in the demos for setFormat that the measures being passed to it are all top level ones and not underneath something else like what we have here with Fact Claim -> Expected.  Is there a special way to pass the measureName parameter to setFormat in this type of case?

Attachments:
ClaimFieldsExample.png

2 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster March 3, 2022

Hello, Darius,
 
Thank you for reaching out to us.
 
Please note that in your case, setFormat method requires receiving the unique name of the field. We suggest checking how the field is defined, for example, in the Slice and using this name to set the format. Please have a look at the following JSFiddle for reference: https://jsfiddle.net/flexmonster/umn95t70/
On the sample below, we set format like this:

flexmonster.setFormat(formatCurrency, "[Measures].[Internet Total Product Cost]");

Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Darius Studdard March 4, 2022

Ok thanks for your assistance.  I had to use your getAllMeasures API to find the proper unique name to use for setFormat and it appears to be working now!
 
Thanks,
Darius

Please login or Register to Submit Answer