# Negative Numbers in Brackets

**URL:** <https://forums.knack.com/t/negative-numbers-in-brackets/19148>\
**Category:** Get Answers\
**Created:** [April 10, 2025, 6:39am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148 "2025-04-10T06:39:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forums.knack.com/u/Michael)\
**Post date:** [April 10, 2025, 6:39am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/1 "2025-04-10T06:39:32Z")

</div>

Hi Folks

Can’t find any posts on this.

I would like to be able to show Negative Numbers in Bracket format

ie (1.5) instead of -1.5

Hoping someone has done this already?

cheers  
Mike

---

<div class="post-metadata">

**Author:** ![CSWinnall](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/cswinnall/32/3631_2.png) [@CSWinnall](https://forums.knack.com/u/CSWinnall)\
**Post date:** [April 10, 2025, 10:32am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/2 "2025-04-10T10:32:43Z")

</div>

Hi @Michael

You can do this by adding a number equation field with this in it

-{Your NegativeField}

Then at the bottom you can select custom prefix/suffix  
Before (  
After )

Craig

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forums.knack.com/u/Michael)\
**Post date:** [April 11, 2025, 5:15am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/3 "2025-04-11T05:15:55Z")

</div>

Thanks for your prompt reply.

I have a P&L field, so both positive and negative numbers, which I sum in a Pivot Table.

Your suggestion adds brackets to all of the numbers, but I may not have understood your advice.

---

<div class="post-metadata">

**Author:** ![LeighBerre96926](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/leighberre96926/32/4896_2.png) [@LeighBerre96926](https://forums.knack.com/u/LeighBerre96926)\
**Post date:** [April 11, 2025, 7:52am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/4 "2025-04-11T07:52:00Z")

</div>

If you are wanting to change it to (1) instead of -1 in a display field or a grid etc, then Craig’s advice is heading in the right direction. probably use =abs({your field}), then set up a third short text field which is your display field - that is conditional such that if its negative it uses the equation, otherwise it uses the original number.

But if you want this to show up in a pivot table, graph, etc then that wont be helpful. You will need some javascript to achieve this. Maybe something like below. Thank ChatGPT for the wisdom …

This is the final edit, I hope - this version also handles currency properly, as per below. Refer all future requests to ChatGPT.

```auto
$(document).on('knack-view-render.any', function(event, view, data) {
  function reformatNegativeCell(cell) {
    let $cell = $(cell);
    let html = $cell.html();
    let text = $cell.text().trim();

    // Check if it's a negative number (with optional $)
    if (/^-\$?[\d,]+(\.\d{1,2})?$/.test(text)) {
      // Remove any minus signs in HTML (safely)
      let cleanedHtml = html.replace(/-+/g, '');

      // Wrap the entire visible number in parentheses
      // We do this only once: wrap the first full number sequence
      let updatedHtml = cleanedHtml.replace(/([\$]?\s*[\d,]+(?:\.\d{1,2})?)/, '( $1 )');

      $cell.html(updatedHtml);
    }
  }

  // Format pivot cells
  $('.kn-pivot-calc').each(function() {
    reformatNegativeCell(this);
  });

  // Format summary row cells
  $('tr.kn-table_summary td').each(function() {
    reformatNegativeCell(this);
  });
});

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/d/d34f35bf31841edad8d6dfa8cc30752fcbadb6d5.png)

displays as

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/d/dbc960f0c3269a5731264430028959745cbcca4e.png)

---

<div class="post-metadata">

**Author:** ![CSWinnall](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/cswinnall/32/3631_2.png) [@CSWinnall](https://forums.knack.com/u/CSWinnall)\
**Post date:** [April 11, 2025, 8:12am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/5 "2025-04-11T08:12:13Z")

</div>

Ah I see.

Ignore this I just realised it won’t work  
Craig

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forums.knack.com/u/Michael)\
**Post date:** [April 12, 2025, 2:26am UTC](https://forums.knack.com/t/negative-numbers-in-brackets/19148/6 "2025-04-12T02:26:39Z")

</div>

> [@LeighBerre96926](#):
>
> javascript

Many thanks Leigh, much appreciated.
