Time format not persisting - excel

I have a calculation sheet, that checks if the rawdata has nothing in it, and if not, it will print the value of the cell.
Somehow, the timeformat is now left centered even though the cell-format and everything is the same as the above data.
I have tinkered with it for hours now and found no solution, so here i am hoping that someone knows what's going on.
SAMPLE FILE: https://ufile.io/dpe9u
Raw Data:
Calculated Data:
Result:
In the calculated data the (local, "HVIS" means "IF")formula is:
=HVIS('80 Rådata'!H951="";"";'80 Rådata'!H951)
I checked formatting and other settings, and everything seems the same, i even formatcopied from the rows where "it worked".

The data in column H sheet "80 Rådata" contains a few time values, but mainly text values that look like time values. Similar in column I, and J and K are all text values that look like times.
You can see that when you select the values and change the cell format to "General". Those that still look like times are text.
To fix that, select one of the columns, then click Data > Text to columns > Next > Next. In this step 3 of the wizard, specify that the data is a date (yes, a date). Then click Finish. Now all values are real time values, which you can verify by formatting as General again (then format back to time).
Repeat that with each column in turn.
From what I can see, the text values all have two zeros in the hour position. 00:01:30. If they had only one zero like this 0:01:30 then Excel would recognize them as time. If you don't want to repeat the data cleanup you may want to change your original data source to produce the correct format.

Related

Avoid Excel Chart streching line till end after series flattens

I have a table of total 12 columns and 30 rows. The table looks like below. Note that real data are very different than this, but follows this pattern - the value goes upto some number and keeps repeating for all rows.
Data
I want to plot a line chart that looks like this-
But I am getting this-
I am able to get an expected chart by manually deleting repeating values from the table. I am looking for a way to do that automatically.
Assuming your data is arranged like this:
You could create another table referring to the first one with these formulas:
So basically, this formula =IF(B3-B2=0,NA(),B3) in H4 copy-pasted in all cells but the first row.
Which would give:
And plotting this second table would give you the desired result since NAs aren't plotted (as mentionned by Solar Mike).
Caveat
This works only if the values are stricly increasing or decreasing for every row. If there is no change between 2 data points before the end of the series where it flattens for good, then there would be missing point in your line.
For example, if 2020.Q2 started with two zeroes in a row, you would have a NA appearing before you want it.
So, you would still need to manually replace those NAs.
But if you want to automate the whole process, you could add another table that checks if there is non-NA values after a NA and if there is change it back to the previous number.
Something like this:
In this solution, the formula in O3 would have to be : =IF(AND(ISNA(I3),PRODUCT(IF(NOT(ISNA(I4:I$8)),0,1))=0),I2,I3)
Explanation:
I4:I$8 is the range of values after the current cell. We use the $ so that the range is anchored to the last row.
IF(NOT(ISNA(I4:I$8)),0,1) returns an array filled with 0's where there is a non-NA value and 1's when the value is NA.
PRODUCT(IF(NOT(ISNA(I4:I$8)),0,1))=0 checks if the product of the elements in the array is 0. Since only one zero is needed for the value of the product to be zero, this essentially checks if there's at least one non-NA value after the current one.
EDIT: If it's impossible for a series in your dataset to reach its maximum before the end, then the solution you found is way simpler. However, the method I'm suggesting is more general since it works whether the series flattens at its maximum, minimum or anywhere in between.
Replace the zeroes.
Use na()
As that is not plotted.
See:
Added benefit: if overlap is set to 100% on the blue series then it looks like the value is "highlighted" in the first series - when discussing data it is a neat way to focus attention.
Edit, this works whether the preceeding values increase or decrease:
So to solve my problem, I created one more table and applied the formula =IF(MAX(B$1:B$8)=H1,NA(),B2). This formula computes the maximum value of the source table column and compares it with the upper immediate value. New table looks like this-
Range of this table is from G1:K8
1-Select a column (or columns) to look for duplicated data.
2-Open the Data tab at the top of the ribbon.
3-Find the Data Tools menu, and click Remove Duplicates.
4-Press the OK button
Is this that you want?

How to find mathematical sum of positive and negative numbers in a single cell in Excel?

I have a column which has positive and negative numbers. I want to find the sum of them. All the values are in Number datatype.
When I use auto sum, I get 0.00 as my result.
Column Image
Also, the values in the column were populated from another columns (like =B2-C2)
However, if I copy and paste the values alone in another column and sum it up, I get the desired result
I agree with BigBen, it sounds like your data is in text format. Even though you change the format on the "Home" tab to "Number", it still might be read by Excel as text.
To quickly change all text "numbers" to real numbers, select the range of numbers and use the "Text to columns" feature under the "Data" tab.
Try making sure that your data is being interpreted as numbers.
For instance, use in E2 "=2*D2". You should get the corresponding number.
Do the same for all your sources cells.
(Given that you mention that these are results from calculations, I expect these to be actually numbers).
If any of the results gives you trouble, you already have the source of your problem.
If all the cells contain numbers, try using in F2 "=SUM(D2:D2)" and expanding the range one cell at a time.
You should be able to identify the source of the problem.
You may help others help you by making your workbook available somewhere online.
You don't need autosum, just SUM (which is anyway the function setup by autosum).

how to auto sorted result from vlookup(google sheet)

I have this formula on google sheet
VLOOKUP(upper(J2:J),colorState!A:B,{2}*sign(row(J2:J)),FALSE)
and I want it to sort the result ascending automatically when I add new data or edit(like arrayformula)
Is there anyway or any formula to do that? (I know that there's SORT formula but I'm not sure how to use it together)
thanks.
I believe I understand what you need :)
Essentially what I understand is that you would like to recreate the "main" sheet but have it automatically ordered by the 'color' column when new data is added. I don't have any idea how to do this to the raw data but you can mirror the raw data by creating another sheet (name 'mainmirror') and in cell A1 just enter this formula:
=query(main!$A:$R,"select * order by P ASC",-1)
It will take you 2 seconds to reformat with a filter view, and you'll be left with a mirror of 'main' that is always sorted by column P and should remain current as data is added.
Hopefully this is an acceptable workaround. Other option would be to use a script but this is less tedious if it's suitable.
Side note: this method will turn your values into strings to mirror them on the duplicate sheet, so on the 'main' sheet I would recommend changing the cell format of column P to a custom number format, 00, which will ensure there's a leading 0 if there's only one digit. this will cause the strings in the mirror to sort correctly, instead of 1,11,12,2,3,4,etc. If you're expecting column P to have 3 digit value, make the number format 000 accordingly.

Excel seems to change format of only some columns

Using VBA, I import a csv file and put a bunch of data into several columns.
One of these columns has a date and time. As I need to be able to use just the 'time' part of these cells, I try to convert the entire column to Time by using (and just about every other variation)
Cells(x.y).EntireColumn.NumberFormat = "hh:mm:ss"
or
Range("C1").NumberFormat = "hh:mm:ss"
Range("C1").EntireColumn.NumberFormat = "hh:mm:ss"
However, this does not convert the entire column. I've tried every possible other way of selecting the entire column and changing it (through VB) however still only a portion remains converted.
If I doubleclick on these unconverted cells and press enter they change to the correct format. I realise this is a common problem relating to Calculations but my workbook is set to Automatic Calculations and I've tried setting this in VB too. This doesn't change anything.
The only pattern I can find is that the cells stop being converted when the Day reaches double digits. For example:
Column C
01/05/2013 7:28:56
03/05/2013 13:24:53
07/05/2013 20:13:24
09/05/2013 8:29:22
12/05/2013 9:28:56
15/05/2013 21:14:25
17/05/2013 7:28:56
Becomes:
Column C
7:28:56
13:24:53
20:13:24
8:29:22
12/05/2013 9:28:56
15/05/2013 21:14:25
17/05/2013 7:28:56
In the formula bar up the top for each cell it still shows the whole Date and Time for all cells, not sure if this is related, but doesn't seem to matter in terms of the calculations i have to perform using the Time.
Essentially I have to take the time for a cell in column C and the time from another Cell (also in Date/Time format) and check the difference. After some research I decided the best way was to convert all the cells to a time format and then do my calculations.
Alternatively I could try converting the column to text and using a Split function (using space as a delimiter) and pulling the time out, but I'm having trouble doing this too, as once again trying to convert the entire column to text stops at the double digits for date.
Thanks for reading through all that, any thoughts and help would be appreciated.
Edit: Realised some of my syntax was incorrect in my post, this was however correct inside my macro
another edit: I think this definitely has something to do with the date format... I just realised that before i format them, the dates are m/dd/yyyy and then when it gets to actual double digit days it changes to dd/mm/yyyy, and thats when the problem occurs...
In order to avoid confusion, and as the date always seems to occupy the same width, I recommend to
1) import this column as a text
2) then go over the whole column
For Each C In Range("A:A").Cells
If C <> "" Then
' ....
End If
Next C
3) cut away the leading 11 positions, e.g. C = Mid(C, 11, 99)
4) convert the remaining string to a time, e.g. C = CDate(C) (... yes it works with a time as well, because a time is a fractional part of a date)
Alternatively you may want to capture the date part and bring it into shape, too. See here for some ideas using worksheet formulas.

Format all cells in column from date to text

I have an excel document with about 500 rows.
I need to format all the cells in , let's say, B column from date to text.
This is how it looks like now:
2012-06-15
2012-06-01
2012-06-14
What it looks like when formated to text:
41075
41061
41074
It has come to my understanding that this is a timestamp representing days since 1st januari 1900, right? Anyhow, this is not what I want. I want the value of the field to be exactly what it is but with the column type of text. I've found various solutions for this using functions like this: =TEXT(B1, "yyyy-mm-dd") but that is not reformating the cell, it is extracting a value from one cell, reformat it and represent is as text in another.
The rule I'm after: I want all cells in B column to have the type text without changing the value
Thanks!
If you have a situation where columns A to D are dates of 500 rows you then:
Use the =TEXT(A1, "yyyy-mm-dd") function you describe in cell E1.
Copy this formula 4 columns wide, and 500 rows down.
Then copy and paste values to the preceding cells.
Copy Example:
Output:
You're right, Excel stores dates internally as number of days since January 1st, 1900 (apart from a minor leap year bug).
Thus, I'm afraid you cannot have both:
Either you keep the value e.g. (41075) and simply format it as a date, so it'll be displayed as 2012-06-15 -
Or you convert it to text format - but then you either
Lose the underlying value - if you convert it to the format you wish with a text function as you mentioned
Keep the value (41075), but cannot see the date
If you are typing in the values you can by adding a ' before the values to keep it as text.
e.g.
But depending on the method the third party service uses to import these values this may not work and I bet you will not get around it unless you export it to a text editor and import it again.
Also try to play with diferent types of text for your third party service, e.g. "2012-06-15" as some see the quotes and remove them.

Resources