May 31 2022 03:57 AM
Morning all,
I have data where there are 20-30 distinct values, and I want to group the data into a smaller number of groups. As an example:
Hostname Events
GGPC-01 5
GGPC-02 12
JEPC-01 50
JEPC-02 20
I want to associate all hostnames starting with GG to the value "Guernsey PCs" and all starting with JE to the value Jersey PCs, so I can produce a table like this:
Grouped Hostname Events
Guernsey PCs 17
Jersey PCs 70
I'm sure this must have been done before (the reason I want to do this is for readability when the query's exported into PowerBI), but can't find a solution. Any pointers appreciated!
Cheers
James
May 31 2022 04:23 AM
One idea
let a = datatable(Hostname:string, Events:int)
[
'GGPC-01',5,
'GGPC-02',12,
'JEPC-01',50,
'JEPC-02',20
];
a
| summarize JerseyPCs = sumif(Events, Hostname startswith "JE"),
GuernseyPCs = sumif(Events, Hostname startswith "GG")
| evaluate narrow()
| project-away Row
| project-rename GroupedHostname = Column, Events = Value
May 31 2022 04:29 AM
May 31 2022 04:33 AM
May 31 2022 06:52 AM
Much as I wish I could say it worked - it doesn't.
Working with the real data now, I've created a sort of intermediate table from Service Principal logins that breaks the data up to three columns:
using | summarize Events=count() by ServicePrincipalName, bin(TimeGenerated, 1d)
I've then put a second summarize in plus my grouping statements, but the result is a table with 5 columns, one row, and a value of false under each column.
Does it need some way of creating a column for the grouped values?
May 31 2022 07:40 AM
SolutionJun 30 2022 08:39 AM