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

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.

Related

Excel Pivot Table difference in columns of "shown as" values

Is there a way to let a pivot table calculate the difference between 2 columns automatically when the values are shown as a % of the parent column total?
Now I need to to manually but the table is dynamic and number of competitors may vary. Function seems so easy but can't find it after googling etc...
See example picture below of what I want to achieve.
(Column F automated by the pivot table is the goal)
If trying to solve this with PivotTables, you've got a couple of options:
Use a 'Traditional' PivotTable that's based on a range. This will give you percentage differences, but you can't get percentage point differences like you're asking for without using external formulas.
Use a 'OLAP' PivotTable that's based on data you've added to the Excel Data Model. This will give you both percentage differences and percentage point differences, without having to resort to using external formulas.
In both cases, I recommend that you unpivot your data first, so that it is in what's known as a Flat File. Currently you're using a cross-tabulated data source (i.e. your source has columns called Year 1, Year 2), and the type of percentage comparisons across years you want to do doesn't work if your data is a crosstab. Basically, PivotTables aren't meant to consume cross-tabulated data.
Instead, you really want your data laid out so that you have a column called Amount and a column called Year, and then you can use the Show Values As options available from the right-click menu to show as percentage differences across years. To transform your data into a flat file, see my answers at convert cross table to list to make pivot table
That said, you can still use the GETPIVOTDATA function on your existing (unpivoted) data layout in a way that is somewhat more robust to changes in your PivotTable structure than just subtracting one reference from the other:
But again, I recommend transforming your data into a Flat File. Then you can additionally do the following:
Using a 'Traditional' PivotTable:
You can kinda solve your problem entirely within a self contained 'Traditional' PivotTable if you drag the Amount column to the Values area, put the Year column in the Columns area, put your Competitors in the Rows area, and choose one of the percentage Show Values As options you'll see when you right-click a cell in the Values area.
I say kinda, because without using external formulas (or without calculating the percentages back in your source data), you can only get it to show percent increases (see far right column), not percentage point increase like you want (see far left column). That said, I think percent increase is less confusing. But I guess it depends on what you want to show. If you want to show say change in market share from one year to the next, then percentage points make sense.
Of course, you could always use the GETPIVOTDATA function to do the additional math for you like we did earlier, like I've done on that left hand side.
Using an OLAP PivotTable based on the DataModel
Calculating percentage point increases likely requires using PivotTables built using the Data Model. See my answer at https://stackoverflow.com/a/49973465/2507160 that explains a little about the Data Model (although it doesn't answer this specific question).
Here's the result:
Here's the measures I used to do this:
Total Year 1:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 1")
Total Year 2:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 2")
% Year 1:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 1")/[Total Year 1]
% Year 2:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 2")/[Total Year 2]
p.p. Diff:
= [% Year 2] -[% Year 1]
You can add Calculated Fields to Pivot Tables, of varying levels of complexity. Finding the difference between two fields is about as simple as it gets.
The example below is borrowed from contextures.com, where there are many more examples more further information.
To add a calculated field:
Select a cell in the pivot table, and on the Excel Ribbon, under the PivotTable Tools tab, click the Options tab (Analyze tab in
Excel 2013).
In the Calculations group, click Fields, Items, & Sets, and then click Calculated Field.
Type a name for the calculated field, for example, RepBonus.
In the Formula box, type =Total * 3%
Click Add to save the calculated field, and click Close.
The RepBonus field appears in the Values area of the pivot table, and in the field list in the PivotTable Field List.
(Source)
EDIT:
#jeffreyweir - I'm not gonna lie, I don't know off the top of my head how to make this work (and don't have time to experiment) but by the looks of these options, isn't a calculated field with a "straight subtraction" of existing fields (ie., 3$-2%=1%) very possible with Difference from? (as opposed to % Difference from which is also an option but for a different result).
In fact, automatic year-over-year difference reporting should be readily possible with the <previous> and <next> comparison operators...?
                                 (Click to Embiggen)
     
Also, did you see the link where I got the example? Kind of a hoakey site but it has some more complex pivot table instructions.

Excel 2016 VBA Display every nth Data Label on Chart

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.

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.

how to get excel graphs to use the same custom date format as a cell mmm-yyyy

I applied a custom date format to a column in excel (the format yyyy-mm e.g. 2014-01)
But when I create a graph out of three columns of data (date-in above format |heading|value) the graph shows the date as 2014-01-31 2014-02-28.
How do I get the graph to display the date as I have formatted it 2014-01 only without changing the data type to text and pasting values?
I use Excel 2013 but as far as I know this aspect of charting has not changed much since long before Excel 2010. Select your horizontal axis (click on one of the date labels in the chart), select Format Axis... and you should be able to:
(a) format the values there independently (ie in your case reapply the same custom format as applied to the raw data) and/or
(b) tick Linked to source.
The latter approach may not work quite as well as the former. Linked to source may mean something a little different from just "take the formatting from the raw data" (well, for the axis labels the format has to be common to all, whereas in the raw data it may differ between data points) and with a quick look I have not found details (for Excel 2010) of exactly what that is supposed to do.
So the former approach may be more reliable. For this you may need a two-step process. First make your custom format available to the chart and then apply it. That way the results are the same, chart and raw data formatting, though the process is not fully automatic.
One thing to watch out for is the linearity of the chart for time values. For example, if the dates are strings and the data points Jan 2012, Feb 2012 and March 2013 there is some risk the resulting labels will be equally spaced whereas the gap between the second two points should normally be thirteen times that of the gap between the first two points. Where data is approximately at regular time intervals anyway this is not always immediately obvious.

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