Azure应用程序见解:如何格式化日期(和数字) [英] Azure Application Insights: How to format dates (and numbers)
问题描述
我需要以一种汇总格式设置格式,以使其生成一种可读的和可排序格式.我正在使用以下代码创建一个时间序列,以汇总几天内的请求数量:
I'm in need of formatting an aggregated date in such a way that it produces an readable and sortable format. I am creating a time series that aggregates the number of requests over a period of days using the following code:
let us_date = (t:datetime)
{
strcat( getmonth(t - 8h), "-", dayofmonth(t - 8h))
};
requests
| project timestamp, client_IP, local_date = us_date(timestamp)
| where timestamp >= now() - 30d and timestamp <= now() + 1d
| summarize uniqueUsers = dcount(client_IP) by usdate = us_date(timestamp)
| order by usdate desc
产生:
数据很好,但是由于格式化,排序顺序已关闭.
The data is fine, but due to the formatting the sort order is off.
要正确排序,应该看起来像05-09
,但我看不到进行这种格式化的方法.
For this to sort correctly should look like 05-09
, but I can't see a way to do this sort of formatting.
请注意,我可以执行以下操作,并以正确的顺序但难看的格式获取数据:
Note that I can do the following and get the data in the right order but ugly format:
let us_date = (t:datetime)
{
strcat( getyear(t - 8h) , '-', getmonth(t - 8h), "-", dayofmonth(t - 8h))
};
requests
| project timestamp, client_IP
| where timestamp >= now() - 30d and timestamp <= now() + 1d
| summarize uniqueUsers = dcount(client_IP) by usdate = bin(timestamp - 8h,1d)
| order by usdate desc
但这会产生非常冗长的列表视图,并且还会将时间嵌入到图表中.
but this produces very verbose list view and also embeds the time into the chart.
有什么主意如何解决数字格式问题,或者如何在查询中获取另一个值以允许排序而不丢掉结果?
Any ideas how to address either the number formatting issue or how to get another value into the query to allow sorting without throwing off the results?
推荐答案
a)您可以在summarize
之后的project
更改列格式,列名或列顺序.
a) You can project
after summarize
to change the column format, column name or column order.
b)您可以格式化bin
的结果.
b) You can format the result of bin
.
这篇关于Azure应用程序见解:如何格式化日期(和数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!