Splunk - Adding pagination - pagination

I have these logs -
2020-01-09 06:20:03,965 - INFO - field1=1 field2=1554
field3=100 host=1
2020-01-09 06:25:03,965 - INFO - field1=2.43 field2=1999
field3=188 host=2
2020-01-09 06:30:03,965 - INFO - field1=3.43 field2=2300
field3=222 host 1
2020-01-09 06:30:03,965 - INFO - field1=4.43 field2=2200
field3=201 host 3
2020-01-09 06:30:03,965 - INFO - field1=4.43 field2=2500
field3=200 host 2
In splunk, I need to add a pagination table that would have "host" as 1st column and the corresponding ("field2"+"field3") as the 2nd column.
Any suggestions on how to do that?

Its not really clear what you are tyring to accomplish, but something like the following may steer you on the right path
index = ... | eval col2 = field2+field3 | table host, col2
You may need eval col2 = field2.field3

Related

Python - Group by with condition

I am trying do gropby function with condition and I am not sure how to get this to work.
Here is how my data looks like:
generated_id timestamp direction date hour
0 1 1590394859141 forward 2020-05-25 04:20:59.141000-04:00 4
1 2 1599758616945 forward 2020-09-10 13:23:36.945000-04:00 13
2 3 1599759625509 backward 2020-09-10 13:40:25.509000-04:00 13
I need to get count of values "forward" direction for each hour. Based on the same data above, I should have one value "forward at 4 and 1 "forward" values for 13.
I am trying to use this:
daily_sum = daily_df.groupby("hour")['direction'].count().reset_index()
Direction can also be backwards so I only need to focus on forward.
How do I do this?
daily_sum = daily_df[daily_df['direction'] == 'forward']\
.groupby("hour")['direction'].count().reset_index()

Combining rows with nearly same fields

I have two data frames and want to combine them into a single data frame. I used a common key to merge two frames. The final result was a data frame that some of rows have nearly identical fields except a few columns have different values. I want to combine these nearly identical rows into a single row considering adding appropriate columns.
Here are the data frames:
stores:
Banner - Region - Store ID
Walmart - NC - 66999
TJ - NY - 4698
prices:
Price - Store ID - UPC
3.6 - 66999 - 234565
4.5 - 4698 - 334526
I already merged tow frames and played a little bit to converge to the desired frame.
store_cross = pd.crosstab(stores['Store ID'],stores['Region'],margins=True)
merged_df2 = pd.merge(store_cross,prices,left_on='Store ID', right_on='Store ID')
merged_df2 = pd.merge(merged_df2,stores,left_on='Store ID', right_on='Store ID')
This is the result so far:
NY - NC - Price - UPC - Banner
1 - 0 - 3.6 - 234565 - Walmart
0 - 1 - 4.5 - 334526 - TJ
It is possible to have a UPC at different stores. It means that there are other rows in the frame that have the same UPC and Banner but at different locations.
What I am looking to have is something like this:
Banner - UPC - NC - NY
Walmart - 234565 - 3.9 - 3.6
TJ - 334526 - 4.5 - 4.3
I believe you need first merge and then DataFrame.pivot_table:
df = pd.merge(stores, prices, on='Store ID')
store_cross = df.pivot_table(index=['Banner', 'Store ID','UPC'],
columns='Region',
values='Price',
aggfunc='sum').reset_index()
print (store_cross)
Region Banner Store ID UPC NC NY
0 TJ 4698 334526 NaN 4.5
1 Walmart 66999 234565 3.6 NaN

Using SUMIFS to sum all rows matching one criteria within a column matched by another criteria

I think I'm very close to what I want but I'm still getting an #N/A error -
I have some wage sheets that cross reference a labour table 'Table1' which stores the information of my employees (Pay code, Site, Contracted Hours etc). In Table1 I have columns titled 1-10 which values.
On the wage sheet I have a cell 'AM3' that will be a number between 1-10. Depending on that cell, the cell below should sum up all values in that column for all staff at that particular site.
For example - I have a wage sheet for site 'EXAMPLE SITE' which is stored in cell C2 and cell AM3 = 9.
I am trying to use the following formula to make this work:
=SUMIFS(INDEX(Table1,,MATCH(AM3,Table1[#Headers]),0),Table1[[Site]:[Site]],$C$2)
That is, I'm checking Table1, and finding the column headed with the value contained in cell AM3 (with an exact match). criteria_range1 is the Site column and criteria1 is 'EXAMPLE SITE' stored in C2.
I would expect this to sum every cell in column header 9, matching Site 'EXAMPLE SITE'. But I just get the #N/A error.
Table1:
Name - Site - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10
Tom - EXAMPLE SITE - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 10 - 20
Geoff- EXAMPLE SITE - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 9 - 18
Sarah- RANDOM SITE - 0 - 0 - 0 - 0 - 0 - 0 - 5 - 15 - 25 - 40
With that example I want the formula to return '19' as a numerical value. I feel like I'm just being dumb but no amount of googling is helping me.
MATCH seems to be having a hard time with matching table headers with numeric values. Try this:
=SUMIFS(INDEX(Table1,,MATCH(AM3,INDEX(Table1[#Headers]*1,),0)),Table1[[Site]:[Site]],$C$2)
Same problem with MATCH as earlier but alternate resolution.
=SUMIFS(INDEX(Table1[[1]:[10]],0,MATCH(TEXT(AM3, "0"),Table1[[#Headers],[1]:[10]],0)),Table1[Site],C2)

Get data from table with multiple criteria Excel

So i have information stored in a table. The columns are the date und rows are the Part. So i have another workbook open with different dates and parts but the table looks completely differnt with some addition rows in between. So i cant just copy&paste the data. I need a vba code to search for the correct entry and copy paste each single value. Similar to a index match function but in vba.
Could you give me some help how to start this?
So that would be my initial table:(Information 2)
Date 1 Date 2 Date 3
Part A 122 134 1212
Part B 453 3 4536
Part C 35 23 3
I need to copy that information into another table with different outline:
Part A Part B Part C
Info 1
Date1 Info 2 122 453
Info 3
Info 1
Date 2 Info 2 134 3
Info 3
Info 1
Date 3 Info 2 1212 4536
Info 3
How could i copy& paste the information into the new table?
How could i do that with index &match funtion?

Copy&Paste Data Multiple Criteria Excel

I need to copy information from one table into another table and i am not sure how to do that.
So that would be my initial table:
Date 1 Date 2 Date 3
Part A 122 134 1212
Part B 453 3 4536
Part C 35 23 3
I need to copy that information into another table with different outline:
Part A Part B Part C
Info 1 - - -
Date1 Info 2 122 453
Info 3 - - -
Info 1 - - -
Date 2 Info 2 134 3
Info 3 - - -
Info 1 - - -
Date 3 Info 2 1212 4536
Info 3
How could i copy& paste the information into the new table?I think Index Match would work but not sure how.
Assuming you table starts from cell A1 as below,
Enter the formula in cell C2 as below,
=IF(MOD(ROW(),3)=0,OFFSET(Sheet5!$A$1,(COLUMN()-2),(ROW()/3)),"")
Drag it to the right and then down to complete the range. This formula refers Sheet5 which you can change it per your needs.

Resources