Creating SUMO logic pie chart with SUM totals - sumologic

I would like to create a SUMO logic pie chart however I am having difficultu doing it with SUM totals. below you can see my query
_sourceCategory=MyAppSource
| parse "* [*] {\"machineName\":*,\"requestPath\":*,\"requestMethod\":*,\"requestSize\":*,\"requestType\":*,\"service\":*,\"duration\":*,\"stack\":*,\"errorMessage\":*,\"errorObject\":*,\"userName\":*,\"clientId\":*,\"statusCode\":*,\"traceIdentifier\":*}" as TimeStamp,Subject,MachineName,RequestPath,RequestMethod,RequestSize,RequestType,Service,Duration,Stack,ErrorMessage,ErrorObject,UserName,ClientID,StatusCode,TraceIdentifier
| if (Duration >= 40, 1, 0) as RequestTimeGreaterThan40ms
| if (Duration < 40, 1, 0) as RequestTimeUnder40ms
| sum(RequestTimeGreaterThan40ms) as RequestTimeGreaterThan40ms, sum(RequestTimeUnder40ms) as RequestTimeUnder40ms
| RequestTimeGreaterThan40ms + RequestTimeUnder40ms as TotalRequest
| (RequestTimeGreaterThan40ms/TotalRequest)*100 as RequestTimeGreaterThan40ms
| (RequestTimeUnder40ms/TotalRequest)*100 as RequestTimeUnder40ms
This produces this result:
However when I look at my pie chart it looks like this
My question:
As you can see my issue is that the pie chart is only grabbing the first value which would be 4.03717 and nothing else. I need to transpose the other columns into rows so that the pie chart can understand that these are different values and they all need to be represented in the pie chart. Does anyone know what would be the best way to do this?

I think the problem with your approach is that you end up counting the requests above-40-ms and below-40-ms in two separate "categories", so then it's hard to "join" them (sorry for not too precise wording).
The cleaner way would be to use single aggregation (not double):
_sourceCategory=MyAppSource
| parse "* [*] {\"machineName\":*,\"requestPath\":*,\"requestMethod\":*,\"requestSize\":*,\"requestType\":*,\"service\":*,\"duration\":*,\"stack\":*,\"errorMessage\":*,\"errorObject\":*,\"userName\":*,\"clientId\":*,\"statusCode\":*,\"traceIdentifier\":*}" as TimeStamp,Subject,MachineName,RequestPath,RequestMethod,RequestSize,RequestType,Service,Duration,Stack,ErrorMessage,ErrorObject,UserName,ClientID,StatusCode,TraceIdentifier
| if (Duration >= 40, "greater", "under") as RequestTimeVs40ms
| count by RequestTimeVs40ms
(Disclaimer: I am currently employed by Sumo Logic)

Related

Dynamic Array vlookup formula (Hlookup in a vlookup ??)

I'm stuck with a complex array vlookup formula.
Explanation:
In one Sheet I have All location worksite
In another sheet, I have all workers.
A simple goal, when a worker has a worksite write in his own line, import other columns via Vlookup. ( Easy )
But I'm trying to do something more: every worker have different type job
I want that the vlookup import a different column for every worker, base on the job type.
So, it's like the return columns have to be different for every worker ... (sound strange)
it's like a vlookup in a vlookup or hlookup in a vlookup?
Any idea how to make this work?
here, a link to the example sheet:
https://docs.google.com/spreadsheets/d/1SY27Hw_Ck24RBJmh5n8hcyt3TrxTm1YPGDKU9DqA7xE/edit?usp=sharing
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, DB_Localisation!A2:AQ,
MATCH(E2:E, DB_Localisation!1:1, 0), 0)))
spreadsheet demo
Instead of using vlookup the second time it's better to use the combination of Index and Match functions. Like this you can get the offset index you need on the first lookup.
so being this my Sheet2:
+---+----+----+
| | 1 | 2 |
|---|----|----|
| a | aa | bb |
in the first sheet I will have
+---+---+----------------------------------------------------------------+
| a | 2 | `=VLOOKUP(B1,Sheet2!A1:Z100,MATCH(C1,Sheet2!B1:Z1) + 1) //bb`|

Sort pie chart's slices without sorting the data in the columns

I haven't found something similar to that on the web, and it seems that the only way for the data to be sorted on the pie chart is if they're pre-sorted.
The problem is that I have a sheet populated by a third party software (Typeform) that places random data, which I then aggregate to present to the pie chart.
More specifically, Typeform writes
town | salary | cost
London | 1000 | 500
Bristol | 700 | 300
London | 900 | 400
Leeds | 600 | 200
Leeds | 500 | 300
Leeds | 400 | 200
Then I aggregate the data in another sheet (Sheet2) so that I have
town | occurrences
London 2
Bristol 1
Leeds 3
Obviously the pie chart will draw London first, then Bristol, and then Leeds. These are only 3 entries, however in my example, I have 20, and the data in the pie chart are not ordered.
Sheet2's data cannot be sorted descending since I am using =UNIQUE(Sheet1!A2:A) and then in the column next to it =countif(Sheet1!A:A,A2) to populate them from the Sheet1 where the 3rd party software is writing them, in fact when I select them and click sort they don't get sorted, they reappear as they were.
Is there any way to sort them (and keep them sorted) in Sheet2, or by writing them in a new sheet?
If town is in A1 of Sheet1 please try:
=query(Sheet1!A2:D7, "select A, count(C) group by A")
Assuming Typeform data is in Sheet1!A:C, the following function in Sheet2!A1 should do the trick:
=QUERY("Sheet1!A:C","select A, count(B) order by count(B) desc",1)
another way to do it is to simply apply Filter on your data, then sort from A-Z (for lowest-highest percentage) or Z-A (for highest-lowest percentage).
Then you create your PIE chart out of that and it comes out sorted!

Dealing with multiple strings and corresponding integers in a single cell

I’ve got a question about something I’m trying to achieve in Google spreadsheets. I’ve got the following table:
| NAME | COUNTRY |
--------------------------------------------------
| Alpha | GER*1, SWE*3 |
--------------------------------------------------
| Beta | GER*5, SWE*1 |
--------------------------------------------------
| Gamma | SWE*5, GER*3 |
--------------------------------------------------
| Delta | SWE*2, GER*1 |
--------------------------------------------------
Now I’d like to be able to calculate how many SWE there are in line Gamma. I’d need spreadsheets to return an integer value, in my example the correct one would be 5.
However, I’d also like to be able to calculate the total number of GER in line Alpha to Delta, also returned as an integer value, in this case the result should be 1+5+3+1 = 10.
As you can see I’m dealing with both strings and integers in a single cell. If it would be possible to for example create an array of all GER*(INTEGER), then delete the GER* and have an array of only the integers that might help me?
I’ve searched here, googled around and fiddled with spreadsheets to try and come to a solution but either I’m too daft or it’s not as trivial as I thought it’d be. Any help would be much appreciated.
To calculate the total number of GER in line Alpha to Delta (assuming your data extends from row 2 to row 5) , try:
=sum(ArrayFormula(iferror(regexextract(B2:B5, "GER\*(\d+)")+0,0)))
To calculate how many SWE there are in line Gamma, try:
=sum(ArrayFormula(iferror(regexextract(filter(B2:B6, A2:A6="Gamma"), "SWE\*(\d+)")+0,0)))
Change the ranges so that they suit your actual data range and see if that works ?
You could use one of the Text functions, like FIND together with MID. REGEXEXTRACT is even more powerful but harder to use. When you have the substring, use VALUE to get the numeric value from it.
For the summary, the easiest is probably to create an extra column, extract the GER value into it as above, and SUM that column.
Here's the function reference for Google Spreadsheets: https://support.google.com/docs/table/25273?hl=en

Performing lookups with merged cells in Google Spreadsheets

Given a set of multi-dimensional data represented in a Google Spreadsheet:
A | 1 | x
A | 2 | y
A | 3 | z
It is pretty straightforward to do a lookup on multiple values using the FILTER and INDEX functions. Doing a lookup for A2 would result in y. However, if the similar data is merged into a single cell:
| 1 | x
A | 2 | y
| 3 | z
Is there a function that would accomplish the same thing? the FILTER method only returns the first row in the implicit set because there is only an A actually on the first row.
If interested, you can view the live sheet here using the 'Rules' sheet.
I have been working on a custom function, but am hoping for something more portable. Helper cells would be fine, as long as I can hide them on a separate sheet.
One option, using the helper cells idea, would be to "normalise" your Rules sheet on a separate (hidden) sheet, and perform lookups on that sheet. Eg, in A3 of that sheet:
=ArrayFormula(HLOOKUP(IF(ROW(Rules!A3:A),Rules!A2),Rules!A2:A,VLOOKUP(ROW(Rules!A3:A),FILTER(ROW(Rules!A3:A),LEN(Rules!A3:A)),1)-1,0))
and fill that formula across to the right as far as required. Note: this formula will only work on the new version of Sheets (which you are using).

Is there a multiple-and-add formula in Google's spreadsheet?

What I want is to easily multiply a number by another number for each column and add them up at the end in Google Sheets. For example:
User | Points 1 | Points 2 | Points 3 | Total
| 5 | 1 | 4 |
-----+----------+----------+----------+------
Jane | 2 | 3 | 0 | 13 (2*5 + 3*1 + 0*4)
John | 1 | 11 | 4 | 32 (1*5 + 11*1 + 4*4)
So it's easy enough to make this formula for the total:
= B3*$B$2 + C3*$C$2 + D3*$D$2
The problem is I frequently need to insert additional columns or even remove some columns. So then I have to mess with all the formulas. It's a pain... we have many spreadsheets with these formulas. I wish there was a formula like SUM(B3:D3) where I could just specify a range. Is there anything like MULTIPLY_AND_SUM(B2:D2, B3:D3) that would do this? Then I could insert columns in the middle and the range would still work.
There is a built in function in Google Sheets that does exactly what you are looking for: SUMPRODUCT.
In your example the formula would be:
=sumproduct(B$2:D$2,B3:D3)
Click here for more information about this function.
You can accomplish that without requiring a special-purpose function.
In E3, try this (and copy it to the rest of your rows):
=sum(arrayformula(B3:D3*B$2:D$2))
You can read about arrayformula here.
As long as you introduce new columns between B and D, this formula will automatically adjust. If you add new columns outside of that range, you'll need to edit (and cut & paste).
On it's own, arrayformula(B3:D3*B$2:D$2) operates over each value in B3:D3 in turn, multiplying it by the corresponding value in B$2:D$2. (Note the use of absolute references to 'lock down' to row 2.) The result in this case is three values, [10,3,0], arranged horizontally in three rows because that matches the dimensions of the ranges.
The enveloping sum() function adds up the values of the array produced by arrayformula, which is 13 in this case.
As you copy that formula to other rows, the relative range references get updated for the new row.

Resources