Excel 2016 VBA Display every nth Data Label on Chart - excel

I have a line chart that displays the revenue of multiple airlines, throughout the period of 2011 to 2016 - with data points plotted quarterly (Q1-Q4, for each year) on the X-axis
I would like to only show the data labels (on the chart) for Q4 of each year, for each airline. I would like to do this and keep the axis as is.
Any suggestions will be much appreciated,
Thank you!
(I have Excel 2016)

Your question didn't express clearly if you want to add the labels by means of a VBA macro.
I suggest to do following:
Dim sData as Series
For i = 1 to sData.Points.Count Step 4
sData.Points(i).ApplyDataLabels
Next i
Note that if there is not value for the Point i in the series, the label seems not to be displayed. It took a while to find out why a label was not added to the chart. To detect this case, I wrote following test:
If sData.Points(i).HasDataLabel Then
If Len(sData.Points(i).DataLabel.Text) = 0 Then
...
End If
End IF

Searching a little in the web (around 3 minutes, that maybe you should spend the same time) found this article:
http://www.cs.mun.ca/~n39smm/Excel/Data%20Label.pdf
This is the resume, but I suggest to view the document because have a lot of graphics.
Click on the bar you want to labeled twice before Add Data Labels.
Click on the label, then right click and select Format Data Labels.
Check the Category Name and uncheck Value.
A little research before asking can save you a lot of time.

Related

Excel chart's data is in Days, can I show the Series Data Lables in Months

My chart's range data ("A1:E6") looks is in the screen-shot below:
And this is my current Projects Timeline chart (Type Stacked-Bar):
As you can see, my Series Data Labels are in the same format as my Range, which is days.
Question: is there a way (without VBA) to format the Data Labels to be in months ?
For instance, for Project 3, Stage 1 (brown bar), instead of 90, it will display 3.
Is there a way to "out-smart" the screen below:
You can use helper columns in your data to calculate the desired value you want to show in the labels, i.e. divide by 30 to arrive at the approximate month value for any given number of days.
Then, depending on your Excel version and/or preference and/or need for backwards compatibility, you can either
manually edit each data label, hit F2 to edit the data label, type a = sign and then click the cell that has the calculated month value. Repeat for each data label, or
if that sounds too tedious, download and install the free XY Chart Labeler tool by Rob Bovey, which automates the steps above. You can share the file with people who don't have the tool, since all label references will end up hard-coded. The tool just helps reduce the manual labour to link labels to the cells. Or
with Excel 2013 or higher, use the formatting option in the Data Labels side panel to use "Values from cells" and select the cells where the converted values are. This feature is not backwards compatible and will show placeholder text instead of the labels if the file is opened in Excel versions earlier than XL 2013.
Edit: By the way, the formatting section that you highlighted in your screenshot is for formatting the numbers that the label shows. A format can only change the display of a value, but not perform a calculation, like convert number of days into number of months. So, the format approach is a dead end from the get-go.

Creating a Stack Area Chart that shows Issues over Time using Beginning and End Dates

My Data looks like this:
||UNIQUE_KEY||LABEL1||LABEL2||START_DATE||END_DATE||
What I'd like to do is have 2 stacked area charts that show totals (count of UNIQUE_KEY), one chart for LABEL1 values & another for LABEL2values over time.
X axis would be Number, Y would be time. Charts would show a count of UNIQUE_KEY for each of the possible LABEL# values at each point in time.
I am at a loss how to translate the Start Date and End Dates into a framework so that excel considers that Issue open at that point in time for the dates that fall in between Start and End date.
I can think of ways to do it that are really ugly and I have to know id there's a slick way to get what I want.
Thanks!
edit... here's a snippet of the data (comma delimited) - and I refined my explanation above
Issue key,Issue Type,Work Type,Created,Resolved
SA-17070,Maintenance,PS_SYSTEM,7/7/2014,8/29/2014
SA-17006,Production Incident,PACKAGING,6/30/2014,8/29/2014
SA-23110,Production Incident,BUSINESS_PROCESS,8/1/2016,9/12/2016
SA-22628,Enhancement,BUSINESS_PROCESS,5/23/2016,8/25/2016
SA-16073,Maintenance,BUNDLE,4/17/2014,5/16/2014
SA-15625,Maintenance,BUNDLE,3/6/2014,3/14/2014
SA-17008,Maintenance,BUNDLE,6/30/2014,7/3/2014
SA-17062,Maintenance,BUNDLE,7/3/2014,7/7/2014
SA-16922,Maintenance,BUNDLE,6/19/2014,7/7/2014
SA-16913,Maintenance,BUNDLE,6/18/2014,7/7/2014
SA-17064,Maintenance,BUNDLE,7/7/2014,7/8/2014
SA-16956,Maintenance,BUNDLE,6/24/2014,7/28/2014
SA-17172,Maintenance,BUNDLE,7/15/2014,8/29/2014
SA-17349,Production Incident,BUNDLE,8/4/2014,8/7/2014
SA-19038,Configuration,BUNDLE,2/16/2015,2/19/2015
SA-19011,Maintenance,BUNDLE,2/12/2015,2/16/2015
SA-19298,Maintenance,BUNDLE,3/12/2015,3/23/2015
SA-19065,Production Incident,BUNDLE,2/18/2015,3/23/2015
SA-19235,Production Incident,BUNDLE,3/9/2015,4/30/2015
SA-20192,Maintenance,BUNDLE,7/13/2015,7/15/2015
SA-21317,Maintenance,BUNDLE,11/19/2015,12/2/2015
SA-21169,Maintenance,BUNDLE,11/3/2015,2/1/2016
SA-21283,Production Incident,BUNDLE,11/17/2015,12/11/2015
SA-21329,Production Incident,BUNDLE,11/19/2015,1/4/2016
SA-23487,Maintenance,BUNDLE,9/12/2016,10/25/2016
SA-23356,Maintenance,BUNDLE,8/29/2016,10/25/2016
SA-23443,Production Incident,BUNDLE,9/7/2016,9/9/2016
SA-23589,Production Incident,BUNDLE,9/24/2016,9/24/2016
SA-23931,Enhancement,BUNDLE,11/21/2016,12/2/2016
SA-17356,Configuration,PS_SYSTEM,8/4/2014,10/7/2014
This is not exactly what you described. This shows dates an issue is open on the Y-Axis, versus the issue number on the X-Axis. I know you want something different on the X-Axis, but it is unclear how you want this to map to the Y-Axis. (e.g. maximum Resolved time - minimum Created time?, duration of latest issue?)
Note: You could do the following once for each Issue Type, once for each Work Type.
To create a chart showing duration an issue is open, where duration is on the Y-axis and the issue "key" is on the X-axis ...
Add a column to your data that is Duration. It is Resolved - Created.
Select the Issue Key Column, Created Column, and the Duration column.
Insert a Stacked Column Chart.
Select the Resolved series and format. Set the fill color and line color to None.
Select the Y-axis and format the axis. Adjust the lower limit to something you want. Change the number format to Date.

Assign Date to PivotTable in Excel

So,
I cannot find a solution.
I have a very large file with timesteps from 1950 to 1970, daily.
I want to plot the date on the x axis with its values on the y axis.
So I marked my values with the dates, clicked on "Insert" and then "PivotChart" and everything looks fine.
I want to define the timesteps shown on the x-Axis (Just every second year i.e.) but it seems that the PivotChart does not recognize that my x-Axis values are dates.
Any Ideas how I can change that?!
Thanks a lot!
I don't think you can use a Pivot Chart according to the Display dates on a category axis article at support.office.com.
I suppose you'll need to use a Line chart if you want to display by every two years.
You can also group the data in the Pivot Table, which will cause a corresponding change in the Pivot Chart. In Excel 2007, that was limited to every year -- without an option for multiple years (as there is for days). But perhaps that has changed in later versions?

Can I display daily data in month buckets using only excel's chart formatting?

I have daily sales figures that I'd like to plot on a simple linegraph.
I would like them to be shown in monthly buckets (i.e. if I sold 5€ on Jan 01 and 10€ on Jan 24, I would like to see only one data point for January with 15€ in it).
Please note that I don't want to use any supporting formula/VBA script, I want to do this using only chart formatting.
I tried setting the chart's X-axis type to "date axis" and I chose "months" as the base unit.
This almost works, but the line graph ends up being kind of weird. Changing the chart type to histogram doesn't help much either. The individual sales are not "piled up" like I would but, instead, they're hidden one behind the other. Stacked histogram doesn't work either.
Any clue on how I can force excel to bucketize my data using only chart formatting? This can't be that hard...
Try creating a pivot chart, then grouping the dates by month (right-click a date in the pivot table, and click "Group by... Month".
If you want to group by Years as well - hold down the Ctrl Key whilst you select the Month (both categories will then show up)

Draw an Excel Line Chart of my account balance

I made a table with my earnings and cash disbursements. And I list the account balance.
Now I want to draw the account balance in a line chart. But the problem is that there isn't a value on every day. So the line between to entries is different because different time lies between two entries. Sometimes three days, sometimes 22 days, ...
How can I realize, that the line is constant after a value and the line only change on a day, with a new value?
Edit (from comment): I'm using Excel 2007
Like the others have said, to get the true time difference between your points to show up, you have to use a scatter plot instead of the Excel line graph.
To display the true state of your balance at in-between dates (i.e., no sloping lines), you'll need to do some transformation of your data. It amounts to creating two new columns of data with duplicate points for each balance: one at the date the account balance reached that level, and one at the date the balance left that level.
I suggest the following:
To populate your Balance column, in the first cell (I'm starting my table at E2) enter
=B2
where B2 is the address of the first balance in your original table. In the next cell down enter
=IF(E2<>E1,E2,OFFSET(B$2,COUNT(E$2:E2)/2,0))
Fill down this formula as far as you need to.
Then in the first cell of the Date column of your new table (I'm starting at D2) enter
=A2
where A2 is the first date in your original table. In the next cell down enter
=IF(E3=E2,OFFSET(A$2,COUNT(E$2:E3)/2,0),D2)
Fill down this formula. Then use this new table as your source data for the scatter plot. Here's a screen capture of a sample:
Are you using an XY-Scatter Plot. A line chart adds in the missing days automatically. Make sure your x-axis is formatted as date.
If you insist on using XY-Scatter Plot then you can put in days for each day, if that day doesn't have data then for the y-axis put in =NA().
I think the chart you need is a step line chart based on your description. The answer of #Excelll above has already pointed out a way to do this in Excel. But here I've another solution that could avoid manually adding some rows to your data. You could use the Funfun Excel add-in to create step line chart. Here is an example that I draw.
As you could see there is some code in the Excel. The Funfun Excel add-in allows you to use JavaScript code directly in Excel so that you could use powerful libraries like HighCharts.js or D3.js to draw charts that could be difficult in Excel alone. In this example, I used HighCharts.js. And it's quite easy to plot this chart since HighCharts.js iteself supports step line chart, so all you need to do is add the step option in your code like the code below.
series: [{
name: "Balance",
data: balance,
step: true,
showInLegend: false
}]
Another advantage of the chart that I showed you comparing to other solution is that you get real time interval in your x-axis. As you mentioned, you may not take record of your balance everyday, the x-axis in the example above shows irregular time interval.
The Funfun also has an online editor in which you could explore your JavaScript code and result. You could check the detail of how I made the example chart in the link below.
https://www.funfun.io/1/#/edit/5a4e478f1010eb73fe125cb2
Once you are satisfied with the result you achieved in the online editor, you could easily load the result into your Excel using the URL above. But of course, first you need to add the Funfun add-in into your Excel by Insert - Office Add-ins. Here are some screenshots showing how you load the example into you Excel.
Disclosure: I'm a developer of Funfun
Excel is really rubbish at charting this kind of thing. In my experience, the best way to chart it is to start with an X-Y plot rather than a line graph, and select the option where it joins the points with a line.
You may also need to add a new column showing "days since start", and use that as the X axis instead of the date - I can't remember whether Excel 2007 can deal with dates properly or not. Try it and see.
Finally, if you include any cells in your chart that are not yet populated (eg because you want to make the chart from the whole column even though you only have a few entries so far), you need to have the empty cells populated with "#N/A" otherwise it will plot them as 0.

Resources