I am trying to figure out how to get labels to show on either Google sheets, Excel, or Numbers.
I have information that looks like this
name|x_val|y_val
----------------
a | 1| 1
b | 2| 4
c | 1| 2
Then I would want my final graph to look like this.
4| .(c)
3|
2| .(b)
1| .(a)
|__ __ __ __
0 1 2 3 4
Like why can't I label each of these points with its name? I can only seem to label the value, e.g, (c) would show 4
Is the only solution D3?
Well I did not think this was possible until I went and checked. In some previous version of Excel I could not do this. I am currently using Excel 2013.
This is what you want to do in a scatter plot:
right click on your data point
select "Format Data Labels" (note you may have to add data labels
first)
put a check mark in "Values from Cells"
click on "select range" and select your range of labels you want on the points
UPDATE: Colouring Individual Labels
In order to colour the labels individually use the following steps:
select a label. When you first select, all labels for the series should get a box around them like the graph above.
Select the individual label you are interested in editing. Only the label you have selected should have a box around it like the graph below.
On the right hand side, as shown below, Select "TEXT OPTIONS".
Expand the "TEXT FILL" category if required.
Second from the bottom of the category list is "COLOR", select the colour you want from the pallet.
If you have the entire series selected instead of the individual label, text formatting changes should apply to all labels instead of just one.
None of these worked for me. I'm on a mac using Microsoft 360. I found this which DID work:
This workaround is for Excel 2010 and 2007, it is best for a small number of chart data points.
Click twice on a label to select it.
Click in formula bar.
Type =
Use your mouse to click on a cell that contains the value you want to use.
The formula bar changes to perhaps =Sheet1!$D$3
Repeat step 1 to 5 with remaining data labels.
Simple
For all those who don't have the option in Excel (like me), there is a macro which works and is explained here: https://www.get-digital-help.com/2015/08/03/custom-data-labels-in-x-y-scatter-chart/ Very useful
Another convoluted answer which should technically work and is ok for a small number of data points is to plot all your data points as 1 series in order to get your connecting line. Then plot each point as its own series. Then format data labels to display series name for each of the individual data points.
In short it works ok for a small data set or just key points from a data set.
If using VBA is an option and assuming that you have a table named 'Table1' of the form:
Label|x_val|y_val
----------------
a | 1| 1
b | 2| 4
c | 1| 2
this routine should work:
Sub labelDatapoints()
Dim r As Integer
With ActiveSheet.ChartObjects(1).Chart 'The scatter plot
.SeriesCollection(1).ApplyDataLabels
For r = 1 To Range("Table1[Label]").Rows.Count 'iterate through all data points
.SeriesCollection(1).Points(r).DataLabel.Text = Range("Table1[Label]").Cells(r).Value 'add the custom label to the current datapoint
Next r
End With
End Sub
Modified from https://www.get-digital-help.com/dynamic-data-labels-in-a-chart/
Related
I want to use a bar chart as a visualisation, to depict the number of times that one of several applications was run on each date (for simplicity sake, think of applications as excel, word, powerpoint etc. For example, on 15-March, if a user opens Excel once, and Word twice, it will show a height of two for Word, stacked with a height of one for excel etc).
The visualisation shows one year of stacked data (365 bars), where each stacked bar uses a different color for each program. There are 20 programs. The dataseries are stacked - for example Word (if it is depicted) is always at the bottom, followed by Excel, etc.
The traditional way to do this is using an outerjoin that creates 365 rows, and 20 columns (Word, Excel etc) with an integer value for each column for each day. This technique works, but is very compute intensive on databases (not to mention dense SQL) and I wondered if anyone knows of a timeseries charting tool that handles this problem.
This is a data pivoting issue: I want to extract the data in rows, and let the charting product assemble the bars. It needs to read the Data Series name from the data, and create a new Data Series whenever it encounters a new value. I actually have thousands of possible Programs, but each chart is unlikely to need to depict any more than 20.
The charting product should work like this:
minDate=20150101, maxDate=20151231, interval=Day
and then the data is
20150315 "Word" 1
20150315 "Word" 1
20150315 "Excel" 1
20150316 "Powerpoint" 1
20150316 "Word" 1
Alternatively, each row could be a total per day per program:
20150315 "Word" 2
20150315 "Excel" 1
20150316 "Powerpoint" 1
20150316 "Word" 1
I am using C3, with spark and scala. I can use any javascript library.
What you are asking is how do you reshape the data from wide to long format. In Spark, you use DataFrame.explode. Assuming you had something that looked like this:
+--------+----+-----+
| date|word|excel|
+--------+----+-----+
|20150101| 3| 4|
|20150102| 1| 2|
+--------+----+-----+
You could reshape it with this:
df.explode($"word", $"excel"){case row =>
Seq(("Word", row.getInt(0)), ("Excel", row.getInt(1)))
}.select($"date", $"_1" as "app", $"_2" as "count")
Into this:
+--------+-----+-----+
| date| app|count|
+--------+-----+-----+
|20150101| word| 3|
|20150101|excel| 4|
|20150102| word| 1|
|20150102|excel| 2|
+--------+-----+-----+
I want to design a report in table format. I am using Panel and Line Control for now, but it's time consuming to adjust. Is there a better way to do this?
Example:
| column1 | column2 | column3 |
| aaaaa1 | sdf | sdfsdf |
| aaaaa2 | sdf | sdfsdf |
| aaaaa3 | sdf | sdfsdf |
The row background color should be alternating (gray & white).
Your question is a bit ambiguous I am going to assume you mean using the Report designer you would like to generate a report that looks like the image below.
That being said you have two different items you have to accomplish the table layout and the alternating Row color.
For the Table Layout
Unless I am missing something this is the easy part you only need to use the field controls and border settings on the controls to generate the grids. I have added a screen cap of the standard layout for the report above in the designer
For the Alternating Row Color
This is the challenge because without a little but of work it cant be done. What you have to do is using the visible expression create two sets of duplicate controls one placed directly on top of each other. I used the row number to build my expression that looked like
=IIf( $RowNumber % 2 = '0', True, False )
=IIf( $RowNumber % 2 = '0', False, True )
That divides each row number by two and if there is a remainder (Bottom equation) shows it and vise versa for the other set of controls.
I'm having trouble graphing some data in Excel properly. I have three columns, which are time, name, and value. If I'm just graphing one name, i.e. "speed", my file looks like this
time | data | value
1 | speed | 1
2 | speed | 2
3 | speed | 3
When I try to graph this, it thinks speed is three different things, and graphs as speed 1, speed 2 and speed 3. I instead want a straight line with a slope of 1, called speed, so it recognizes that they're all the same data. Ideally, I could add in extra data names such as acceleration, and it would treat all of those the same too.
In Excel 2007: Go to insert --> Scatterplot and create the chart type "Scatter with smooth lines".
Give a mouse right click on the chart and pick "Select Data" option.
Click on Add series button and place "Series X values" as the range of values in column Time and fill in "Series Y values" with the range data on column Value.
If you have additional rows with data meaning something else than speed, like acceleration you can add a second series to make the second line in the graph.
Example:
looking for a starting point for my task.
Situation:
I have three Excel worksheets that have the same structure and contain the following columns amongst others:
|ID|SubID|SubName|Description|Link1|Link2|
|1|1|SubName 1|Desc SubName1|P00001|P00002|
|1|2|SubName 2|Desc SubName2|P00002|P00003|
|2|1|SubName 1|Desc SubName1|P00001|P00002|
here comes a line that contains more than one P-Number inside a cell:
|3|1|SubName 1|Desc SubName1|P00001,P00002,P00003|P00001,P00002|
I now would like to look through the Link1 column and place those values with the first three columns in a sorted order to a "Link1" worksheet like so:
|P-Number|ID|SubID|SubName|
|P00001|1|1|SubName 1|
|P00001|2|1|SubName 1|
|P00001|3|1|SubName 1|
|P00002|1|2|SubName 2|
|P00002|3|1|SubName 1|
|P00003|3|1|SubName 1|
And I would like to do the same with the Link2 column also placing the values to a seperate worksheet.
The next step would be to concatenate the P-Number of the new sheet with a string that works like a link. That's what I have working so far.
Another idea would be to make the SubName clickable and have it jump to the according name in one of the three worksheets.
I'm not sure if a macro is the right choice or maybe a Pivot table could also do the trick.
Any ideas are appreciated.
Thanks.
UPDATE:
I tried to incorporate this concept to my main macro where I also process the columns mentioned above. However since I have several loops running through this part the output line will be over-written by the last P-number of the column. I use this Sub:
Sub PrintArray(Data As Variant, Cl As Range)
Cl.Resize(UBound(Data, 1), UBound(Data, 2)) = Data
End Sub
And this call for testing:
PrintArray NewArray, ActiveWorkbook.Worksheets("Link 1").Range("A2")
How can I "save" each P-number to the new sheet without having to use a loop inside my code?
Pivot tables can't split 1 cell into multiple rows, so the starting point of a VBA solution would be:
load input range into an array (my_array = Range(...).Value2)
for each row, split Link1 (link_array = Split(my_array(current_row, 5), ","))
for each link, append the link and other values into a results array
place the results onto a worksheet
sort the resulting range
Is there a way to generate comma-delimited values in Excel (optimally using a PivotTable)? Consider the following data:
Object Color
foo Red
foo Blue
bar Red
bar Blue
bar Green
baz Yellow
I'd like to get a table like the following:
Object Count of Color Colors
foo 2 Red,Blue
bar 3 Red,Blue,Green
baz 1 Yellow
Is this possible in Excel? The data is coming from a SQL query, so I could write a UDF with a recursive CTE to calculate, but this was for a single ad-hoc query, and I wanted a quick-and-dirty way to get the denormalized data. In the end, it's probably taken longer to post this than to write the UDF, but...
Here's a much simpler answer, adapted from this superuser answer (HT to #yioann for pointing it out and #F106dart for the original):
Assuming the data is in columns A (Category) and B (Value):
Create a new column (C), and name it "Values". Use this formula, starting in cell C2 and copying all the way down: =IF(A2=A1, C1&","&B2, B2)
Create a second new column (D), and name it "Count". Use this formula, starting in cell D2, and copying all the way down: =IF(A2=A1, D1+1, 1)
Create a third new column (E), and name it "Last Line?". Use this fomula, starting in cell E2, and copying all of the way down: =A2<>A3
You can now hide column B (Value) and filter column E (Last Line?) for only the TRUE values.
In summary:
A B C D E
+--------- ----- ----------------------- ------------------- ----------
1| Category Value Values Count Last Line?
2| foo Red =IF(A2=A1,C1&","&B2,B2) =IF(A2=A1, D1+1, 1) =A2<>A3
3| foo Blue =IF(A3=A2,C2&","&B3,B3) =IF(A3=A2, D2+1, 1) =A3<>A2
etc.
Yes, you would be much better off using the tools of whatever RDBMS you're running (MS SQL, MySQL, etc.).
Such a pivot table is possible in Excel. But, only if you write a cumbersome VBA module -- which I don't recommend.
However, the task is simpler in MS Access -- which usually comes bundled with Excel. Microsoft makes it "easy" to link Access and Excel and to use the former to run queries on the latter.
So, given the spreadsheet cells as stated:
For best results, sort the table by Object and then by Color.
Make sure the spreadsheet is saved.
Open up MS Access.
Select File --> Open (CtrlO)
Under Files of type, select Microsoft Excel
Navigate to and choose your existing spreadsheet.
Choose the worksheet or named range that contains your table.
Give the linked table the name MyPivot.
Open the Visual Basic Editor... Tools --> Macro --> Visual Basic Editor (AltF11)
Insert a module and paste in this UDF:
'Concat returns a comma-seperated list of items
Public Function Concat (CategoryCol As String, _
ItemCol As String) As String
Static LastCategory As String
Static ItemList As String
If CategoryCol = LastCategory Then
ItemList = ItemList & ", " & ItemCol
Else
LastCategory = CategoryCol
ItemList = ItemCol
End If
Concat = ItemList
End Function
Save the project and close the VB editor
Under Queries, Create a new query in design view.
Switch to the SQL View.
Paste in this SQL:
SELECT
Object,
COUNT (Color) AS [Count of Color],
LAST (Concat (Object, Color)) AS [List 'O Colors]
FROM
MyPivot
GROUP BY
Object
Run the query (Press the red exclamation mark or just select the Datasheet View).
Voilà, done in 15 easy steps! ;)
Results:
Object Count of Color List 'O Colors
bar 3 Blue, Green, Red
baz 1 Yellow
foo 2 Blue, Red
An even easier way is to add the data to the data model when you create the pivot table and then use a "measure" (called "Colours") as follows:
=CONCATENATEX(Table1,[Color],", ")
Then add the "Colours" field to the values portion of the pivot.