How do I break out of an array?

I am trying to format a number that is in the millions so that it is easily readable. My number comes to me as an array with just this one number example for ten million [10000000]

When I am unable to do things that I expect to work with functions I always find it best to put the object into a variable so that I can see what is going on.

here you can see the source JSON
1

here I am mapping it to my variable
2

and here you can see my output from mapping the variable
3

I then try to format the number
{{formatNumber(75.RoundSize; 0; β€œ.”; β€œ,”)}}

because this is an Array I get this error.
4

if I try:
{{formatNumber(75.RoundSize[1]; 0; β€œ.”; β€œ,”)}}

Then I can get it to work.

How can I write this directly without setting the variable?

If I try
{{formatNumber(map(72.entity.fields; β€œvalue.data[1]”; β€œid”; β€œfield-2943646”)[1]; 0; β€œ.”; β€œ,”)}}

It will look like this
image

and I get this error
image

Hello @aottarsson,

When you set RoundSize variable, the result of the map() function is an array.
When you try to run formatNumber on an array, you get that error.

When setting RoundSize, you can use the first() function on the array (the result of the map() function) to get the first element from the array. Then, formatNumber() should work.

3 Likes

Hi @aottarsson

The map function will provide an array as output. Therefore, you need to use the get function to pass the data as a number.

We have provided a sample format that you can adjust to your requirements.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes