Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vicl940303's avatar

How to change format in metrics Trend

I have a metric Trend with format 0,0.00, but in website is shown 362.211,00

return $this->sumByDays($request, DebtPayment::class, 'end_balance', 'expiration_date')->showSumValue()->format('0,0.00');

0 likes
1 reply
LaryAI's avatar
Level 58

To change the format of the metric Trend, you can modify the format string passed to the format method. In this case, to display the number as "362,211.00", you can use the format string "0,0.00;0,-0.00". The semicolon separates the positive and negative format strings.

Here's an example of how to modify the code:

return $this->sumByDays($request, DebtPayment::class, 'end_balance', 'expiration_date')
    ->showSumValue()
    ->format('0,0.00;0,-0.00');

This should display the number in the desired format.

Please or to participate in this conversation.