I was hoping if somebody could give me a light to an Excel problem I'm trying to solve.
I have two tables. One called SENSOR and the other one CARD
1 - Table SENSOR has a date/time in one column and employee ID on the other
2 - Table CARD has a date/time in one column and employee ID on the other
The only exact match is the employee ID. The date/time from table SENSOR is not an exact match from table CARD (it is usually a couple of minutes plus or minus). What I need to do is to return on cell C1 the date/time column from table CARD that is the nearest time found in date/time column from SENSOR table.
TABLE SENSOR:
Column A: DATE/TIME
11/3/17 10:48
11/3/17 16:02
11/10/17 7:09
11/13/17 20:58
11/15/17 21:24
11/16/17 11:32
Column B: EMPLOYEE ID
7164
7165
7166
7163
7167
7163
TABLE CARD:
COLUMN I: DATE/TIME
11/3/17 16:05
11/10/17 7:10
11/13/17 21:04
11/15/17 21:30
11/16/17 11:40
11/3/17 10:45
COLUMN J: EMPLOYEE ID
7165
7166
7163
7167
7163
7164
Here is what I'm trying to do (It actually works in some of them, but in some others it just doesn't work and I can't understand why):
C1 =INDEX(I$2:I$285,MATCH(MIN(ABS(I$2:I$285-A16)),(J$2:J$285=B16)*ABS(I$2:I$285-A16),0))
Thank you guys
Since you mentioned TABLES I used TABLES and structured references. Makes things a bit easier, in the long run. But you should be able to translate to direct references, if you need to.
Here is the formula:
=LOOKUP(2,1/(AGGREGATE(15,6,(ABS(([#[EMPLOYEE ID]]=CARD[EMPLOYEE ID])*
CARD[DATE/TIME]-[#[DATE/TIME]])),1)=ABS(([#[EMPLOYEE ID]]=CARD[EMPLOYEE ID])*
CARD[DATE/TIME]-[#[DATE/TIME]])),CARD[DATE/TIME])
compare employee ID in Sensor with employee ID in card
return an array of the matching date times or zero's (if not match)
subtract from that the date/time in the current row and return the ABS value
using LOOKUP, return the last time that is in the same position as the minimum (ABS) difference.
the AGGREGATE function is used to avoid dealing with error values. It also allows avoiding using ctrl+shift+enter for array formula.
Related
I have a table like this:
Year Num Freq. Exam Grade Course
2014 102846 SM SM Astronomy 3
2015 102846 12,6 1,7 NC Astronomy 2
2017 102846 20 11,8 17 Astronomy 2
2015 102846 SM NC Defence Against the Dark Arts 4
2015 102846 11 4,5 NC Herbology 2
2015 102846 15 13,99 14 Herbology 2
I am trying to get the percentage of approved students (Grade >= 10) for each course by year and global average.
I've been trying for nearly 3 hours to do a calculated field but so far the only thing I could get was the sum of each student per year:
I have tried to do a calculated field with = Grade >= 10 hoping that it would give me a list of approved students but it gives me 1.
What am I doing wrong in here? It's my first time working with pivot tables.
I would really recommend to not mix string type (text) together with numbers. It's a horrifying idea and will cause a lot of headache when data will be used for calculations (both Freq. and Grade). Rather I would use 0 or some numeric value to represent the text.
Not recommended, but yes it's doable =)
You need some dummy variable to point out which row is number and which is text. So I created Grade Type. We can now count only the rows that have a number in the Grade column by using Grade Type = Number.
I create a table of the data and add the column Grade Type. I use this formula to get Grade Type:
=IF(ISNUMBER([#Grade]),"Number","Text")
I then create the following measures:
Nr of Approved Students
=COUNTX(FILTER(Table1, Table1[Grade Type]="Number"),
IF((VALUE(Table1[Grade])>=10),VALUE(Table1[Grade]),BLANK()))
First we filter which rows that should be evaluated (COUNTX(<table>,...)). If yes, then only count for rows that fulfill >=10, where VALUE() converts string number to numeric (COUNTX(...,<expression>)).
Nr of Student (w/ Grade Number)
=COUNTX(FILTER(Table1, Table1[Grade Type]="Number"), VALUE(Table1[Grade]))
Count all rows that have a number
Approved (% of Total)
=[Nr of Approved Students]/[Count of Grade]
Setup the PowerPivot Table
Create the PowerPivot and add the data to the data Model
Then create a new measure by clicking your pivot table and then "Measures" -> "New Measure..."
Fill in all the relevant data.
Result should be something like:
I have Start date + time and End date + time in table 1, then i have a range of dates and values in table 2. what i want is to find the highest value from table 2 that happened in the date range from table 1.
For example in table 1:
start date 12/30/2020 08:03 ; end date 12/31/2020 17:26
in table 2 is:
12/30/2020 08:00 1145
12/30/2020 09:00 2145
12/30/2020 10:00 3912
12/30/2020 08:00 1472
and so on. so in the row of table 1 i want to see the number 3912
Suppose both of your tables are structured reference table as shown below:
You can use either of the following formula to return the desired value:
=MAX((Table2[Date]>=Table1[#[Start Date]])*(Table2[Date]<=Table1[#[End Date]])*Table2[Value])
This one is using MAXIFS as suggested by Nicholas Hunter in the comment section:
=MAXIFS(Table2[Value],Table2[Date],">="&Table1[#[Start Date]],Table2[Date],"<="&Table1[#[End Date]])
Assuming table 1 = A1-B10 and table 2 is in D1-10,
try making another column (lets say F1-10) with the following: =IF(And(D1<B1,D1>A1),D1,0)
and in whatever cell you want the highest Date, put =Large(F1-10)
Make sure that the final cell has "Date" format, otherwise it will look like a weird number. if you want to look at the intermediary steps, do the same for F1-10.
I'm trying to create a top3 ranking from a data table varying metrics but each time I get the wrong order from the cuberankedmember, usually misplacing ranks 2 and 3.
The data I'm mostly focused on is regarding sales revenue. Power pivot sums all sales by store, quite straight forward.
From this I use a cubeset formula that captures store name, filtered by a month and year, which the user types in as any day for the month, and set the measure which to sort by (NTS) (code 1).
The cuberankedmember selects the cubeset and defines the position (code 2).
Then the cubevalue selects as members the cuberankedmember, filters once again month and year, then pulls in the measure (code 3).
E4 is the date
Code1 (cell C21):
=CUBESET("ThisWorkbookDataModel";
"NONEMPTY([Store_Dict].[Nome_DSR].children,
([Calendar].[Year].[All].["&YEAR($E$4)&"],
[Calendar].[Month Number].[All].["&MONTH($E$4)&"]))";
"Ranking";
2;
"[Measures].[NTS]")`
`Code2` (cell `D22`):
`=CUBERANKEDMEMBER("ThisWorkbookDataModel";$C$21;1;"a")
`C21` is the `CUBESET` formula
Code3:
CUBEVALUE("ThisWorkbookDataModel";
$D22;
"[Calendar].[Month Number].["&MONTH($E$4)&"]";
"[Calendar].[Year].["&YEAR($E$4)&"]";
"[Measures].[NTS]")
Actual Result:
Ranking Store NTS
1 a 606
2 c 425
3 b 428
Expected result:
Ranking Store NTS
1 a 606
2 b 428
3 c 425
I have a report pulled from KRONOS daily and emailed to me which has 4 columns. The names are down the first column, employee ID, type of pay, hours to pay in that order. I just need to combine the hours so that there is one value per row and just one name. I tried using an easy pivot table but that failed for 2 reasons.
I couldn't figure out how to sum duration of hours in 00:00 format
(tried every single option in field settings) either got N/a or the count of instances.
Even if it worked, I would like to figure out how to exclude the 1.00 hour penalty from the type of pay column indicated by "LP CA Meal Penalty"
I tried to paste the actual tables here but it wouldnt let me so below is my best attempt to replicate issue for one employee.
Curt, Cathy 90066408 LP CA Meal Penalty 1.00
Curt, Cathy 90066408 LP Overtime 1.77
Curt, Cathy 90066408 LP Regular 8.00
Result desired:
Curt, Cathy 90066408 = 9.77
Do Not want: Curt, Cathy 90066408 = 10.77
Assuming your data is in Column A:D and result needs to be displayed from Column G,
To get all the unique Names from Column A enter the following formula in Cell G2
=IFERROR(INDEX($A$2:$A$9,MATCH(0,INDEX(COUNTIF($G$1:G1,$A$2:$A$9),0,0),0)),"")
Drag/Copy down as required. Change range $A$2:$A$9 as per data in Column A.
Now, to get corresponding Employee ID, enter the following formula in Cell H2
=VLOOKUP(G2,A2:D9,2)
or
=INDEX($B$2:$B$9,MATCH(G2,$A$2:$A$9,0))
Finally, to get Total Hours, enter the below formula in Cell I2
=SUMIFS($D$2:$D$9,$A$2:$A$9,G2,$C$2:$C$9,"<>LP CA Meal Penalty")
or
=SUMPRODUCT(($D$2:$D$9)*($A$2:$A$9=G2)*($C$2:$C$9<>"LP CA Meal Penalty"))
See image for reference.
EDIT :
=SUMIFS($D$2:$D$9,$A$2:$A$9,G2,$C$2:$C$9,"<>LP CA Meal Penalty",$C$2:$C$9,"<>LP CA Rest Break Penalty")
or
=SUMPRODUCT(($D$2:$D$9)*($A$2:$A$9=G2)*($C$2:$C$9<>"LP CA Meal Penalty")*($C$2:$C$9<>"LP CA Rest Break Penalty"))
Seems like all you need to do is filter by your third column and exclude in the filter the "LP CA Meal Penalty".
Attached are examples of my result and my filter selection on my pivot table.
Result gotten
Filter excluding the unwanted work hour type from the sum
Let me know if this works for you.
You can use SUMIFS as the example I show you above and the formula to use is:
=SUMIFS($D$2:$D$9,$A$2:$A$9,F2,$C$2:$C$9,"<>"&"LP CA Meal Penalty")
This will exclude LP CA Meal Penalty from the computation.
Also, for the time format, the requirement is not so clear but this is hh:mm what I understand that you want. The formula you can use is:
=TEXT(H2/24,"hh:mm")
Please tweak the range that fits your data structure and let me know if this is what you are asking for.
The scenario I'm facing is that in my company we have mixed naming conventions for servers and workstations like:
COUNTRYCODE-WORKSTATION1
WORKSTATION10-COUNTRYCODE
COUNTRY-SERVER1
SERVER1-COUNTRYCODE
So sometimes I may find names like: BR-WK1 or SRV42-US.
I need to create a PivotTable to extract the amount of events per country so I need to come up with a Lookup function that looks at the first two characters in a cell and if it finds a country code it returns the country code in a country column for that row. If it does not find a country code, it looks at the first two characters on the right, and so on. Country code list will be available in another sheet.
IF(LEFT(CELL,CHARNUMBER){COUNTRY LIST}) then (CELLCOUNTRY == {MATCH COUNTY}))
ELSE(RIGHT(CELL,CHARNUMBER){COUNTRY LIST} then (CELLCOUNTRY == {MATCH COUNTRY}))
Excel:
COUNTRY MACHINE NAME EVENT DATE TIME
BR BR-WK1 Critical type 1 08/01/2015 01:15
US SRV42-US Critical type 2 08/01/2015 01:15
BR WK100-BR Warning type 8 08/01/2015 01:15
US US-SRV420 Critical type 1 08/01/2015 01:15
Pivot table:
Row Labels Count of EVENT
BR 2
US 2
Grand Total 4