Seems this one have a similar problem: https://laracasts.com/discuss/channels/nova/nova-value-metrics-format-not-working
It convert number 12143 to 12.14k
No solution posted though :/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I'm trying using Laraval Nova Trend Metric, but the output is wrong.
Do you guys know why I get numbers like this 0.90k, 0.80k, 0.70k instead of 900, 800, 700 ?
Database screenshots here: https://imgur.com/a/Xk9qPbq
Nothing fancy added at all in my application.
Have tried to delete everything a few times, but the result always end up the same and I have absolutely no idea what is causing it :(
What can cause this problem? Any help is very much appreciated.
<?php
namespace App\Nova\Metrics;
use App\Models\Purchase;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
class PurchasesPerDay extends Trend
{
/**
* Calculate the value of the metric.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return mixed
*/
public function calculate(NovaRequest $request)
{
return $this->sumByDays($request, Purchase::class, 'amount');
}
/**
* Get the ranges available for the metric.
*
* @return array
*/
public function ranges()
{
return [
30 => __('30 Days'),
60 => __('60 Days'),
90 => __('90 Days'),
];
}
/**
* Determine for how many minutes the metric should be cached.
*
* @return \DateTimeInterface|\DateInterval|float|int
*/
public function cacheFor()
{
// return now()->addMinutes(5);
}
/**
* Get the URI key for the metric.
*
* @return string
*/
public function uriKey()
{
return 'purchases-per-day';
}
}
@mb That division is right , simply because we count amounts of money per thousands.
You can experiment with the format you want by referring to Nova Docs: https://nova.laravel.com/docs/3.0/metrics/defining-metrics.html#value-result-formatting
To customize the display format, you can use the format method. The format must be a format supported by Numbro:
Example:
public function calculate(Request $request)
{
return $this->count($request, User::class)
->format('0,0');
}
Please or to participate in this conversation.