Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

Visualization API - Numeric formatting in pivot table

Hi everyone,

I am having an issue when trying to format a measure field when creating a pivot table visualization on-the-fly.  The definition of the measure is:

{

      "qDef": {

        "qLabel": "Value",

        "qDef": "Sum(Value)",

          "qNumFormat":{

          "qType":"F",

          "qnDec": 2,

          "qUseThou": 1,

          "qFmt": "# ##0",

          "qDec": ".",

          "qThou": " "

          }

      }

    }

I would like to format the number so that it shows the thousand separator as a space and displays 2 decimal places, but I have tried various options and it is always displayed with 3 decimal places and no thousand separator.  I assume that hs qNumFormat is being ignored for some reason.  Anyone have any ideas?

Thanks in advance.

1 Solution

Accepted Solutions
ErikWetterberg

‌Hi,

yes I got that. This feels like a bug. You could try Settings the format with setOptions https://help.qlik.com/en-US/sense-developer/April2018/Subsystems/APIs/Content/CapabilityAPIs/Visuali...  but that’s more of a workaround.

Erik Wetterberg

View solution in original post

10 Replies
ThomasGorr
Partner - Contributor III
Partner - Contributor III

Hi Richard, where did you change the settings of qDef? If you've set them in the initialProperties, you need to remove the extension and add it to the sheet again. If you didn't, please provide your code in more detail.

ErikWetterberg

Hi,

Have you tried settings this format in the client and then using /options/developer to see the property structure?

Erik Wetterberg

https://extendingqlik.upper88.com/

rbartley
Specialist II
Specialist II
Author

Hi Thomas,

Thanks for responding.  Sorry, I should have specified that I am doing this in a mashup, not in an extension.

rbartley
Specialist II
Specialist II
Author

Hi Erik,

Thanks for replying.  As per my response to Thomas,  I am doing this in a mashup. 

rbartley
Specialist II
Specialist II
Author

Even though I copied the definition in my script from the Qlik Help page

https://help.qlik.com/en-US/sense-developer/June2018/Subsystems/APIs/Content/CapabilityAPIs/Visualiz...

and is as follows:

"qDef": {

 

        "qLabel": "Value",

        "qDef": "Sum(Value)",

"qIsAutoFormat": false,

"qNumFormat": {

          "qType": "F",

          "qnDec": 2,

          "qUseThou": 0,

          "qFmt": "#,##0.00",

          "qDec": ".",

          "qThou": ","

        }

When I output the created visualization object to the console.  I can see the following

qMeasureInfo: Array(2)

0 :

autoSort: true

cId: "ykyyGCs"

numFormatFromTemplate: true

qApprMaxGlyphCount: 14

qAttrDimInfo: []

qAttrExprInfo: (2) [{…}, {…}]

qCardinal: 0

qFallbackTitle: "Value"

qIsAutoFormat: false

qMax: 17857575117.98

qMin: -48318.507

qNumFormat:

qDec: "."

qThou: ","

qType: "F"

qUseThou: 0

qnDec: 3

__proto__:Object

qSortIndicator: "D"

__proto__: Object

It seems as though my settings are being overridden.

rbartley
Specialist II
Specialist II
Author

BTW, I am using the April 2018 version of Qlik Sense

ErikWetterberg

‌Hi,

yes I got that. This feels like a bug. You could try Settings the format with setOptions https://help.qlik.com/en-US/sense-developer/April2018/Subsystems/APIs/Content/CapabilityAPIs/Visuali...  but that’s more of a workaround.

Erik Wetterberg

ErikWetterberg

Hi,

From the documentation, there seems to be two other options that can be relevant:

numFormatFromTemplateBoolean

When enabled, the number format to use can be selected from multiple predefined formats based on the desired type: number or date.

Default: true

isCustomFormattedBooleanSet to true to toggle off the default client formatting.

Have you tried those?

Erik Wetterberg

https://extendingqlik.upper88.com/

rbartley
Specialist II
Specialist II
Author

Hi Erik,

Thanks for responding again.  Yes, I have tried those two options, so I'll look into your idea of using setOptions and I'll let you know whether this resolves the issue.