[英]Kusto Query Language: set column name of summarize by evaluated expression
Me again asking another Kusto related question (I really wish there would be a thorough video tutorial on this somewhere).我再次问另一个与 Kusto 相关的问题(我真的希望在某个地方有一个关于这个的完整视频教程)。
I have a summarize
statement, that produces two columns for y axis and one for x axis.我有一个
summarize
语句,它为 y 轴生成两列,为 x 轴生成一列。 Now i want to relabel the columns for x axis to show a string, that i also got from the database and already put into a variable with let
.现在我想重新标记 x 轴的列以显示一个字符串,我也是从数据库中获取的并且已经用
let
放入了一个变量中。
This basically looks like this:这基本上是这样的:
let android_col = strcat("Android: ", toscalar(customEvents
| where application_Version contains secondLatestVersionAndroid));
let iOS_col = strcat("iOS: ", toscalar(customEvents
| where application_Version contains secondLatestVersionIOS));
... some Kusto magic ...
| summarize
Android = 100 - (round((countif(hasUnhandledErrorAndroid == 1 ) * 100.0 ) / countif(isAndroid == 1), 2)),
iOS = 100 - (round((countif(hasUnhandledErroriOS == 1) * 100.0 ) / countif(isIOS == 1), 2))
by Time
|render timechart with (ytitle="crashfree users in %", xtitle="date", legend=visible )
Now i want to have the summarize display not Android and iOS, but the value of android_col and iOS_col.现在我想要汇总显示不是 Android 和 iOS,而是 android_col 和 iOS_col 的值。
Is that possible?那可能吗?
Best regards Maverick最好的问候小牛
Generally, it's suggested to have predefined column names, otherwise various features don't work.一般来说,建议有预定义的列名,否则各种功能都不起作用。 For example, IntelliSense won't know the names of the columns, as they would be determined at run time only.
例如,IntelliSense 不知道列的名称,因为它们只能在运行时确定。 Also, if you create a function that returns a dynamic schema, you won't be able to run this function from other clusters.
此外,如果您创建一个返回动态架构的函数,您将无法从其他集群运行此函数。
However, if you do want to change column names, you definitely have a way to do it by using various plugins.但是,如果您确实想更改列名,您肯定可以通过使用各种插件来实现。 For example, bag_unpack , pivot and others.
例如bag_unpack 、 pivot等。
As for courses on Kusto, there are actually several excellent courses on Pluralsight (all are free):至于Kusto上的课程,Pluralsight上其实有几门优秀的课程(都是免费的):
此查询中“toscalar”的用法看起来不对,在我看来,您应该使用具有相同逻辑的“extend”运算符来创建附加列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.