This is going to sound ridiculous, but I'm really struggling to follow along with the examples in Spotfire 6.5:
I have a line chart, where I'm trying to produce a cumulative sum of sales. I have dates on the x-axis, correctly identified as DateTime format in Spotfire, and volumes on the y-axis.
I have the custom expression:
Sum([volume]) then Sum([Value]) over (AllPrevious([Axis.X]))
... but I get an error message saying "Could not find axis: 'X'" in the visualization.
Interestingly the UI on the y-axis selector has changed to read "Cumulative Sum (volume)", so I think I must be close... It's just the final hurdle to get over!!
To be completely explicit about this: Should I be using [Axis.X] in my expression, or something like [Date]?
Sounds like your X axis isn't categorical, but continuous. In that case the axis won't be available for an OVER expression.
Your Y axis expression looks correct.
If you right-click the x axis expression and select "Custom Expression...", the expression for the axis needs to begin with '<' and end with'>'. This means Spotfire will treat values as categories, rather than as measures on a continuous scale.
You can also see this by going to X-Axis property page -> Settings button
The data looks like this:
Dates Sales Cumulative sales
2001-01-09 10 10
2002-01-09 20 30
2003-01-09 30 60
2004-01-09 40 100
2005-01-09 50 150
and the expression for 'Cumulative sales' is:
Sum([Sales]) OVER (AllPrevious([Dates]))
Is it what you are looking for ?
Related
I would like to use weeknumbers in number formatting in Excel, in particular in XY-graphs.
The built-in function WEEKNUM() can be used to extract the weeknumber from a date. With these weeknumbers I can proceed in two different manners:
use the weeknumbers as text labels on my graph axis. This does not give the required result as labels are distributed evenly on the axis. A sequence like "13" "14" "33" would put the label "14" just in the middle.
use the weeknumbers as numbers on my graphs axis. This would resolve the above problem, but gives a gap at years end. E.g. 1652 (week 52 in 2016) and 1701 are 49 units away from each other.
To illustrate, please see these two graphs. The graphs indicate a tracking of a project plan, i.e. planned versus actuals. The first chart is a correct graph somewhere in the midst of a year; the second chart is more or less the same graph crossing year's end.
Correct chart, in the midst of a year
Chart showing problem at year's end
Now I'm stuck. My preferred route would be to add a number format to the generic number formatting methods in Excel. E.g. similar to be able to use yyyy for years and ddd for days, I'd like to use ww for weeknumbers.
How can I achieve this?
Not certain I'm understanding the question fully, but if you're wanting to ensure the end result is treated as a number you could use =Text(WEEKNUM(A1), "#") which would convert it to a numeric value.
For the chart, sounds like you could use the axis options (right click on the axis labels >> Format Axis). There are multiple options that would allow you to change how the labels are displayed.
After a couple hours of work I come to you guys with this graphing problem. I need to create a Milestone-Trend-Analysis which can be seen on the german wikipedia , though not in the english version.
General Information
In short, the diagram has report dates on the x-axis (for now, on every first of the month, another report is due).
The y-axis should mirror the x-axis completely. In length and also the tickmarks. The dates get bigger from the bottom to the top.
In my case the x-Axis is on top of the diagram.
Every report consists of a number of "due-dates", one for each assignement in progress. They are the estimated "finishing dates" of that particular assignement.
If the estimated finishing date stays the same in the next report period, the graph for that assignement stays on the same level. If the estimate is earlier, the graph trends down. Normally they go up, since the assignement has some delay :-D
The x-axis needs to be dynamic, since the whole project is basically finished when its last assignement is finished. If one of the assignements is running late, the whole project gets delayed an thus the x-axis needs to be longer/get more ticks.
Since the y-Axis mirrors that, it has to change too.
MY PROBLEM
The x-axis has a number of discreet values, since the reports come in every month, or every two weeks. But that does not change.
The values for the finishing dates are continuous, since the assignements can be terminated whenever.
That leaves me with the problem of having to cut the y-axis in equal-size chunks, although the months of the year are not equal in size. At least that is, what I think excel forces me to do.
I can assign a max limit and a min limit for the y-axis and I can assign a distance between each main tickmark. Since Excel works with a continous number for each date, the 2014/01/01 would be 41640. And 2015/01/01 is 42005. Since I have 12 month on the x-axis and I need 12 on the y axis, I would have to have the main Ticks at a distance of 30.42 ... which gives me the following Months on my axis
January January March .... December December
Does anyone know an answer for this? Is there a way to have excel make the tickmarks on the y-axis not equal distance?
Any input greatly appreciated.
Kaz
I did not find a way to make Excel have variable tick mark distances. But since I coud not have it that way, I had to make the month equally long.
This works for me now:
'calculate the norm for different type of month including Schaltjahr
Select Case cellMonth
'February
Case 2
'Schaltjahr and Schaltjahrhundert
If (cellYear Mod 4 = 0) Or (cellYear Mod 400 = 0) Then
resultDay = (30 / 29) * cellDay
Else
resultDay = (30 / 28) * cellDay
End If
'31 day months
Case 1, 3, 5, 7, 8, 10, 12
resultDay = (30 / 31) * cellDay
'30 day months
Case Else
resultDay = cellDay
End Select
Now I just have to scale the axis to numberOfMonths * 30. It now leaves adjusting the names of the y-Axis, which seems to be a whole different story.
Kaz
You can put arbitrary labels along the Y axis by adding a dummy XY series.
Here is some data that I think captures your issue, plus a line chart showing the data, plus the data that I'll use to construct a dummy Y axis.
I used a line chart so the X axis at least would be easy. You just have to make sure that the axis is formatted as a date axis with Base Unit of Days.
Here is how I built the axis.
Top Left Chart Below: I copied the dummy axis data, both columns of the data includingt the header row. I selected the chart, and used Paste Special to add the data as a new series, data in columns, series names in first row, categories in first column (but don't replace existing categories).
Top Right Chart Below: I right-clicked on the added series, clicked on Change Series Chart Type, and selected XY Scatter with Lines and Markers. Excel also put this series onto the secondary axes.
Middle Left Chart Below: I formatted the added series to be plotted on the Primary axis.
Middle Right Chart Below: I changed the scale of the vertical axis, giving it a minimum of the first date and a maximum of the last (1/1/16 to 9/1/16).
Bottom Left Chart Below: I formatted the vertical axis to show no labels.
Bottom Right Chart Below: Format format format. I formatted the dummy axis series so it used light gary lines (matching the horizontal axis) and light gray cross markers (simulating tickmarks). I changed the tickmarks of the horizontal axis so they crossed the axis, matching the cross markers of the dummy series. I added data labels to the left of the dummy series points, simulating vertical axis labels.
I have a table (came from a pivot table) where I have formatted the column 4 cells to show 1 billion as 1. But when I select the table and insert a chart, I am getting my units in millions. So the 14.8 billion number for Mexico is showing up as 14,800 on the chart. Why might this be happening and how can I fix this? This is also making all my other bars negligibly small. Note that the first three columns are not in billions and are totally different things. Some are percentages, some are other small numbers.
Table:
Chart:
You need a secondary horizontal axis and some formatting on the Axes.
In Excel 2013
First change the Chart Type to Combo and select Clustered Bar for both sets of data, then Check
Secondary Axis for the Percentage Series.
Then set up the axis limits so they match, e.g.
Percentage: min -.5 max 2
Billions: min -5e9 max 20e9
Then set the percentage format on the source data to a custom Number format of "";(0)%;0%
Then set the Billions format as 0,,,;"";0
You will get something like this:
EDIT
Now that we have the general principles, we can apply them to your specific data.
I will also switch to Excel 2010 do show the different menus.
The data selection looks like this
Select the non-Billion series (plural!) and check the secondary axis
If the larger data is always positive then you can use custom formatting to clean up the axis
Align the primary and secondary axes so that the grid lines match on both
The end result is clean and readable.
Mixing percentages and numbers for the smaller numbers is not handled by this but I would suggest that that would be confusing anyway?
The simplest way to fix this might be to plot cells containing the billions values divided by 10^9 rather than to plot the billions themselves, though via a secondary axis may be possible.
Using Excel 2007. For the purple bars, the example on the left uses ColumnE values, on the right ColumnF values. E1 contains =F1/10^9 and F1 contains =14800000000:
It appears that there are 3 questions here: 1) "Why might this be happening", 2) "how can I fix this", and 3) something like "how can I plot data which lie on two widely differing ranges, and make them all reasonably visible anyway", even if there was no explicit question on this.
There are several ways to solve issue #2 about the units (e.g., billions) and numbers (e.g., 14.8 vs. 14,800.0) shown in the axis, each one with its own pros and cons:
Use Format Axis -> Axis Options -> Display units.
This might be the answer to your issue #1 as well, you might have the following selection: Display units -> Millions, and unchecked Show display units... Otherwise, I wouldn't know why you chart shows what it shows.
Use faked tick marks, as indicated in the (excellent) site of Jon Peltier
http://peltiertech.com/Excel/Charts/ArbitraryAxis.html
It gives detailed instructions on how to create tick marks on an axis with arbitrary labels (which may be text, numbers, etc.), which is more generic than what the OP wants here. In this particular case, the labels will be the desired numbers.
Create new cells containing data that would be plotted exactly the way you want.
As for your issue #3, I guess the only option is to have a Secondary Axis (see the answer by pnuts).
Thus, to come up with the best final chart for you might use a combination of one of the options I gave here and a secondary axis.
I'm having some issues using custom number format in Excel. I want the numbers on the y-axis of a scatter graph to be number formatted, so 16 on the y axis is labelled as a grade G, 22 as a grade F, 28 as a grade E, and so on. The following code works and formats my G and F correctly.
.Axes(xlValue).TickLabels.NumberFormat = "[=16]""G"";[=22]""F"";"
When I try to add any more formats in, say;
.Axes(xlValue).TickLabels.NumberFormat = "[=16]""G"";[=22]""F"";[=28]""E"";"
It no longer works. Is there a way around this problem?
NB: My y axis major unit is set to 6 and the axis minimum is set to 16, so all the grades I want lie on the tick markers.
This is a limitation of Excel, unfortunately: a number format can contain up to 2 conditions.
This is confirmed here. I've looked around for the original Microsoft documentation for this but I can't find it. What I can say, however, is that all of the example format codes I've seen on Microsoft pages have up to two conditions, never more than two. I guess they were not expecting users to need more than two conditions.
One workaround: See Jon Peltier's article on how to make arbitrary axes scales. His example:
I have 3 columns of data, eg:
http://i.stack.imgur.com/XjGmu.jpg
When Excel creates a line graph of this, the blue line is what i get.
This is not correct because the time stamp shows the time when something is switched on (255) or off (0) (could also be the current state eg 16:08). So I'd like a graph like this - see the red line (with a time-based X axis off course):
http://i.stack.imgur.com/vNvPk.jpg
Anyone can help? Thanks
As #Jon49 indicated, you need to plot additional data points--two y values for each x value: one to plot the point at y=255 and one to plot y=0.
If the time-span of the data is at least a few days, you can use a line chart. But in your case since the values are within a day, the scatter chart with straight lines is the only option due to the limitations of the scale units for line charts.
The key is the values need to be in the correct order. Each y=255 value needs to be followed by the next time-stamp's 255 value followed by it's 0 value, followed by the next time-stamp's 0 value:
Excel doesn't support this type of discrete value graph (at least not excel 2k3 that I am using); your best bet is to use a bar graph and then go into the settings and set the gap width down to zero.
Not sure what the best way is but I would automate what I describe below on how to do (unless this is a one time deal, then just brute force it):
Separate the 255s from the 0s. Make sure for every 0 time there is a corresponding 255 time. Take the zero times and put in a scatter plot then add a y-error bar and make the fixed value equal to 255. Format to how you like it.
Now for the 255s. Add those to the chart by pairs. Make the chart type for these pairs scatter plot with a line. Format how you would like them to look.
Let me know if that doesn't make sense to you.