Excel, deleting columns with Zero value and graphing 1000's of points - excel

I have a spreadsheet with 1000's points that I want to graph.
Y axis are dates, X axis is time, values are electricity consumption in Kwh.
As you can see updates are in 15min intervals but every other is 0.
a) I want to delete the 0 columns.
b) And graph the result > 255points
excel.jpg

To delete every other column without doing it manually, you can create a formula to help. First insert a row at the top of the sheet (you will delete this row when you are done with it.) Next, in your new helper row, add a MOD function to the first column with the Kwh values (probably column B.) This returns a remainder after we make a division, so we pass the column function to it as our number parameter. The other parameter is the divisor so we will use 2 for that.
=MOD(COLUMN(),2)
With the cell selected, click the bottom right square of the green highlight of that cell (when your cursor turns to a +) and drag it across all of your columns. Now we will have a 0 and 1 in every other column.
We want to convert that formula to values to make sure nothing happens to our data so now copy the highlighted cells and right click to paste special. Here you will change the Paste radio button to Values.
Now we have values in the helper row so we can select all of our columns except the date row, so do that and open the data column. Click the Sort icon and in the sort window now you will click options and choose from left to right. We will then choose to sort by row 1, and choose the order to be smallest to largest.
Now when you click to sort you will have all of your columns with 0 in them (if it was indeed every other column) on the right-hand side, and all of your data is in the left. Easily select all of the zero rows now and delete them manually with one click. Also delete the helper row you created and you have the sheet ready to graph.
Select all of your data including column A and Row 1, and then go to the insert tab. In charts you can see the different types of graphs. Check the recommended charts or experiment by clicking on the different types of graphs to see which one fits your needs the best. If you choose the 2 Line or Scatter for instance, it will graph out each day in different colors showing Kwh on the Y axis, and X will be the time. You can then format as you wish.

Related

Is there way to autofill in excel where every blank row in a column is filled with the value of the closest non-empty cell above the blank row?

A simplified example of what I am looking for is a quick way (either a tool or a keystroke) to fill a table where every 5 rows of the first column has a different operator name. The fill would place the first name into the first 5 rows of the table, the second name into rows 6 - 10, and the third name into rows 11 - 15. The images below are a visual representation of before and after the fill.
I am aware of different ways to fill the rows one operator at a time in this example, but is there a way to fill all three in one go? This would be very helpful in larger scale situations. Thanks!
Excel table before filling column A
Excel table after filling column A
Open PowerQuery (Go to Data on the ribbon, Get Data -> Launch Power Query Editor ...) and use Fill Down ...
Result

In excel, how can I automate a sheet to be filled based on conditions of another sheet?

Is there a way in excel to copy the contents of one column to another sheet based on particular values in another column.
I have data which looks like this:
Sheet1:
Sheet2:
I would like to copy the column A of sheet 1 directly onto column A of sheet 2, but only if the value in column B is Y.
I have tried used the match function but am not sure how the best way to do this would be. Is there a way for me to achieve this?
My desired output is:
As discussed in the comments, #Waldorf99 was looking to have a second worksheet that would automatically show a filtered list from the first sheet. I can think of a few ways to do this (array formulas or pivot tables come to mind). The problem with mixing dynamic columns with static values is that the static values would become desynced from the dynamic ones.
In the original example, rows may have a blank value in the condition column in sheet one, and then may be assigned a Y or N at a later date. If a Y is assigned to a row in the middle of other rows, the filtered sheet would shift the existing rows down to make room. The static values would stay where they were, and would become desynced. To demonstrate:
If the above image is the original state of sheet 1 and 2...
...adding a y next to x.1.c would result in sheet two shifting columns A and B of row 2 down, but leaves columns C and D behind (as they are static, and not tied into the first two columns in any way).
One thing that may work as you are wanting are filters. You would only have one sheet, with all of the data manually entered. Then you can add filters, and change them to hide rows temporarily when needed.
To add and use filters:
Start with your data all on one sheet...
Highlight your data...
On the Home tab, select "Format as Table" and choose any style...
This turns your data into a table. You can filter by clicking the drop down in a given columns header row, then deselecting the values you want to hide.
The results are a table that only shows the rows with a 'Y'.
The other rows aren't removed, just hidden. You can always reset or change your filters, to configure which rows are visible.
Note: when working with tables, they will auto expand to account for new rows, so long as you work in the row directly under the table (e.g. don't leave blank rows). You can also manually resize the table at any time by clicking and dragging from the bottom right corner of the table.
There are tons of resources of Excel tables online, and it's a pretty useful tool in Excel.
Hope that achieves what you were looking for.

Generate summary gantt chart from detailed activities

I want to create a gantt chart summary that shows a person´s whole "busy" and "free" schedule by day and in a single row, from a detailed gantt chart with a list of activities of different people in multiple rows.
Basically go from this:
To this: (which I created Manually)
To be able to give a summary of people´s shifts free time between activities.
Right now I´m just using this formula to compare the start and end date in each row and produce a "1" if the condition is True, then I just condition formatted the whole Gantt cells.
=IF(AND(Q$8>=$N12,DAY($K12)<>DAY($J12)),1,IF(AND(Q$8>=$N12-0.00001,Q$8<$O12-0.00001),1,""))
I have no idea how to start. I was thinking of doing the nest things:
Create a table of the names of all the possible people to be added in the gantt chart.
Program the macro to create a new sheet with the same template.
Program a loop which starts iterating with each person´s name:
For each person´s name which exists in the gantt chart to be summarized, start creating new rows per each day they have activities scheduled (I can´t figure out yet how I´d iterate through this).
Within the each person´s loop, start iterating each row on the original sheet, evaluating each start and end date´s and pasting on the new sheet´s current person´s current day row a "1" if the condition was true in the corresponding hours.
Loop until all individual activities of each person are finished.
Continue with next person.
I´d like to know if this is the logical way to go and if you have any pointers or similar code to recycle, I am not proficient in VBA and Excel macros.
Not sure if I understand properly, but it looks like you got a set of multiple records where you store the times In and Out of each worker, several rows for each worker.
And based on that, you would like to resume data, one row per worker, highlighting start and end time of each worker, but all in a single row.
I made a fake dataset like this:
I added 2 extra columns (you can even hide them if you don't want to see them)
Field START TIME got this formula:=B2-INT(B2)
Field END TIME got this formula: =C2-INT(C2)
In Excel, Dates are integers values and times are decimal values. I used both formulas to get only the decimal part of each start and end.
All this data is a table object named T_WORKERTIMES. I made a table object so if you add new records, the Gant Chart will autoupdate.
Then I made a simple (kind of horrible) Gant Chart:
The formula I've used in H2 and drag is:
=COUNTIFS(T_WORKERTIMES[Worker];$G2;T_WORKERTIMES[start time];"<="&H$1;T_WORKERTIMES[end time];">="&H$1)
Actually, all my data is in same sheet:
I added 2 Conditional Formating Rules to highlight cells in green/white if the result of the formula is 1/0.
Also, working with times sometimes can be hard, because decimals. 0,677083333335759 means 16:15. But 0,6770833333333333 too, so in Gant Chart I rounded up headers to 6 decimals.
My formula in H1 is =ROUND(7/24;6)
My formula in J1 and drag to right is =ROUND(H1+1/24/4;6)
So now everything works fine. Please, notice in worker 1, there is no activites from 07:00 to 08:00. So I add a new row with that data and everything updates:
I've uploaded a sample yo Google Drive you can see the formulas and hope you can adapt this to your needs.
https://drive.google.com/file/d/1KOuCAYsmlY9gfNUCUhIrihXu-tJz-K7t/view?usp=sharing
Biggest issue here is the decimal part of times, to make sure they fit the Gant Chart. An easy solution would be substracting just 1 minute to start time column (calculated, you can hide it) and sum 1 minute to end time column (calculated, you can hide it).
Hope this can guide you in your project.
It looks like you are trying to extract unique records per person and day to get a person/day summary of time availability but also want it to be automated as you add more people and days.
I was able to do this with a combination of powerquery and a pivot table. When new persons/dates are added or changed the report will update but you will need to refresh using CTRL+ALT+F5
you want to highlight your entire report or an area as big as you think it will get. While highlighted you will then utilize named range feature under FORMULAS tab -> DEFINED NAMES ribbon -> DEFINED NAME dropdown. We could name it REPORTAREA or something like that.
Make sure you change the conditional format formula in report to show 0 instead of "" so this can work properly
2 go to DATA tab -> GET AND TRANSFORM ribbon -> From other sources -> Blank Query.
This will open the power query editor as a blank query
3 In the formula bar type =Excel.CurrentWorkbook() case sensitive is important
4 From there you will see CONTENT and NAME column.
In the NAME Column select the drop down and go to TEXT FILTERS -> Equals... Type in the name of your named range so the query does not pick up anything else on accident.
5 Remove the NAME column by right click selecting it and then remove.
6 you will notice the CONTENT column has two curved arrows pointing left and right instead of straight down like you are used to in excel. Click these arrows and make sure you uncheck the "use original column name as prefix" option box and ensure that the EXPAND option is selected. Then click okay.
7 At this point it looks alot like your report. Go to the HOME tab -> TRANSFORM ribbon -> Use first row as headers.
8.Select only the columns that are NOT THE 24 hr STYLE TIME LABELS of your report and then right click -> Unpivot other columns
9 At this point you can start removing some of the columns you dont want by right click and remove. Also double click and rename the columns as you wish. You can right click the top of the column and change types to what you want.
Dont worry about the 24HR style time zones not looking correct as this will be fixed later, this column should be changed to decimal type and not time zone type.
select a column that has the date information you need and right click -> Duplicate column -> change type to date.
11.At the top left part of the screen there is a CLOSE AND LOAD drop down where you will load to a new worksheet.
That will produce a green table. Select the table and press ALT+D+P to produce a pivot table linked to the green table you produced from the query.
You may need to close the Queries and Connections box that opened in order to see the pivot table options that will appear on you right.
Drag the 24hr style column to the columns area.
Drag the People to the Rows area and after Drag the Column you made in step 10 to the Rows area.
Drag the conditional format column to the Values area.
Your pivot table wont look exactly like what you want. while pivot table is selected go to DESIGN tab -> REPORT LAYOUT -> Tabular and also SUBTOTALS -> DO NOT SHOW SUBTOTALS while in the same tab.
13 Highlight all of the 24hr style time labels and format them and after highlight the inside of the pivot table where all the 1 and 0 will be and apply the conditional formatting you applied previously. Dont forget you changed the formula originally so your if statement does not end with "" but instead with 0.
If you would like i think it is easier to switch around the ROWS and COLUMNS area of the pivot table fields so that the report is easier to read. I have chosen to do so in the pictures. If you want to keep the report the way you are used to you can follow previous instructions.
I put the above comment down here as a complete answer.
I call those cells after "Finish date" column as "Chart cells". To extract a unique list of names, please refers to: here
If each name, you can use the followings formula and format for cells value >0 to show the bars.
=SUMIF([name range], "[each name]", [for each column of the chart cells])
If you further needs to filter by dates, you need to use sumifs() instead:
=SUMIFS([each column of chart cells], [name range], [unique name obtained from above], [Finish date range],"<=" & DATEVALUE("[target date]")+1,[start date range],"<=" & DATEVALUE("[target date]"))
This is the Excel formula solution, which is good if your table is not huge.

Multiple series into one line in line graph in Excel?

I'm trying to make a line graph in Excel that combines multiple series into ONE line. All I've been able to create so far is one graph with multiple lines on the same y axis. Is it possible to combine multiple data points from multiple series together in chronological order?
For context: I'm trying to make a graph that shows monthly temperatures between 1880-2017. January, February and so on, are each a separate series. I can make a bar graph that shows each year with each month chronologically but is there a way to convert this into a line graph without it producing multiple lines for each month, but instead one line that combines all the month data points together nicely?
Thanks!
If there no gaps in the data you described,
and you have a table
of (2017-1880+1)=138 rows by 12 columns.
Here it is one way to make a one-line graph of the data
(some random imaginary data used in the example).
Unfortunately, standard Excel data functions can handle only
dates not older than January 1, 1900,
see for example, http://www.exceluser.com/formulas/earlydates.htm.
But you are lucky as all you need is just a year and a month numbers.
In this case the dates along the x-axis
can be presented with numbers, which integer part is the year,
and fractional part is a fraction of the year that represents a month.
Assuming that the table is in Sheet1!A2:M139,
select Sheet2 , type in a formula
=1880+FLOOR((ROW()-2)/12,1)+MOD(ROW()-2,12)/12
in the cell A2, and copy it down to A1657 by any means you like.
For example, select A2, press Ctrl+C,
click in the Name box input field,
type A2:A1657 range in it and press
Ctrl+V.
That's it, this will create all the
x-axis date values for the one-line graph.
Next step is to fill the range B2:B1657
consequently with monthly data from the Sheet1.
Select cell B2 and type in a formula
=TRANSPOSE(INDIRECT(ADDRESS(2+LEFT(A2,4)-1880,2,,,"Sheet1")&":"&ADDRESS(2+LEFT(A2,4)-1880,13)))
select range B2:B13,
click at the end of the formula and press
Ctrl+Shift+Enter.
The range B2:B13 is now filled with the T data from Jan to Dec of 1880,
and it is still selected.
Press Ctrl+C to copy this range,
then select B14:B1657 and press Ctrl+V.
That's it, all the readings from the table
will be lined in the range B2:B1657.
Edit
There is even simpler solution for the second part:
fill the range B2:B1657 with formula
=INDEX(Sheet1!$B$2:$M$139,FLOOR((ROW()-2)/12,1)+1,MOD(ROW()-2,12)+1)
It just converts a linear x coordinate of the current point,
based on the subsequent row number ((ROW()-2)) into corresponding row, column pair
in the table and extracts the table value with INDEX() function.

Sort a column in excel

My column values looks like this.
Q1-2011 (1st quarter 2011 )
Q1-2011
Q1-2012
Q2-2011
.
.
.
I want to sort this column by having all the the quarters of year 2011 then 2012 and so on and so forth. However when I try to do the normal sort it gives the Q1 of all the years then Q2..till Q4. Please help me sort the column year wise.
Thank you
So you have a column with text "Q1-2011" Here's how to do the sort.
Open up the spreadsheet.
Do you see the column with the "Q1-2011" in it? (I'm going to call this column A) Select the column header to the right of it. Right Click, insert. Do this again, Right Click, insert. This step creates two empty columns to the right of your original "Q1-2011".
Copy the entire column "Q1-2011" to the left most of the two columns you just created. (that would be column B. At this point column C is blank)
Select the column you just filled with the copied data, with a left mouse click. The selected area should be highlighted in blue.
On top menu in Excel, choose the Data tab, then choose Text to columns
You should see a pop up box. Select Delimited --> Next. Select Other and in the box add - the minus sign --> Next, and finished.
Now sort your data. Select the entire sheet. (left click, area to be sorted will be in blue.) Choose Data Tab then select Sort. You will see a popup box. Sort by column C (the year) first, then add a level (see the button?) than sort by column B (the quarter)
Now hide columns B and C .
All done!
I believe you'd have to create another column to bring back a date in the quarter and then filter on that.

Resources