I have some data that summarizes unit count by week by year. IOW's, my datatable looks like this:
Week/ 2012/ 2013/ 2014/ 2015
1/ 45/ 45/ 31/ 28
2/ 45/ 52/ 54/ 58
3/ 40/ 42/ 62/ 51
4/ 41/ 50/ 58/ 50
5/ 43/ 46/ 58/ 46
6/ 41/ 49/ 56/ 56
...and so on (sorry about the formatting). I am displaying this data in a Google Line Chart - multiple lines, one line for each year. My challenge is: how to display (alpha) months on the x-axis of the line chart? (Currently I get week numbers, which don't mean much to anyone!)
SEE COMMENTS BELOW FOR ANSWER
If your starting point is a dataset with "by week" data you wont be able to use it for displaying monthly data. Not accurately anyway.
What you really want to do is to change your query so as to get a dataset with monthly data.
Related
I am trying to calculate monthly average temperatures for a dataset with daily temperature values that spans three years. With the data.frame appearing like this example"
Date Month Temperature
12-2-2016 December -10
12-3-2016 December -12
01-2-2017 January -15
01-3-2017 January -14
02-3-2017 February 3
02-4-2017 February 7
03-2-2017 March 8
03-3-2017 March 9
I tried running the following code in order to create a new dataframe with the Month and the average temperature:
group_by(df$month) %>%
summarise(mean_airtemp = mean(Temperature))
However, when running this code I get NA for certain months which I believe is attributed to negative values. I have tried to figure it out but have only found solutions that seem to separate the values based on whether they are negative or positive.
you can use groupby of month and temp together
df.groupby(['Month'])['Temperature'].mean().reset_index(name = 'avg')
Spotfire question: I have a data table with monthly data that is visualized in a bar chart. I however also want to visualize the information in quarters, by showing the latest month of the quarter in the format '20Q1, 20Q2, etc.'. (So I don't want to use standard 'date format'.)
My idea was to create an additional column that is filled for March, June, Sep, Dec and empty for the other months. Then with a document property, the user can select to either view the data in months or in quarters (i.e. the last month of the quarter).
So far so good, my data now looks like this:
Month
Value
YearQuarter
Jan-20
100
Feb-20
200
Mar-20
400
20Q1
Apr-20
125
May-20
101
Jun-20
300
20Q2
The problem now is that when I visualize the data with YearQuarter on the x-axis, it also shows all the (empty) values in a bucket. See below. How to solve this? Note that the x-axis has a custom expression "<$esc(${Granularity})>", where Granularity is a document property to determine what column to pick.
Did you try limiting your data with whatever expression you have put in x axis.
Thanks
I have my graph set up, so that a sum total is in rows, and month is in columns. I would like to see the last three years as separately colored bars or lines in the same graph. I created sets for 2014,2015, and 2016, but for some reason can not get it to do what I have described above.
Thank you.
One way would be to create a calculated field that "groups" those 3 years into one value/label, then use that in the colors card.
The calculated field may look something like:
IF [YearField] >= 2014 AND [YearField] <= 2016 THEN 'Last 3 Years' ELSE STR([YearField]) END
I have built a bar chart visualization with Spotfire that includes the use of the Over function to give a running total. Months are on the X axis and counts are on the Y axis.
My data set contains months where there were no values. When I graph that there is no bar although a running total should still contain a value although zero was added for that month.
How do I get a month with no value to still show a bar for that month?
Yes, You can try Count() OVER (AllPrevious([Axis.X])), this will work for bar chart and line chart. or if you r using 55.0 and above version you can use Cummulative function which is inbulit is recent versions.
Hope this help :)
Here is my data set (note the 2 missing values):
Month Value
Jan-14 1
Feb-14 2
Mar-14
Apr-14
May-14 5
Jun-14 6
Jul-14 7
Aug-14 8
Sep-14 9
Oct-14 10
Nov-14 11
Dec-14 12
Here is my expression (taken from the built in Cumulative function):
Sum([Value]) THEN Sum([Value]) OVER (AllPrevious([Axis.X]))
Here is my result:
So it looks like your expression is wrong.
since I saw this old topic and didnĀ“t find a solution at first, there it is:
the formula is good, but displaying the months with no values is an option of the bar chart itself.
Go to the bar chart "Properties", then "Appearance", then at the bottom of the window: tick the box "Compensate for missing values".
Hope this will prevent next users from searching in the future :)
This relates to my How do I achieve a pivot report in Crystal Reports for Visual Studio? The data is the same, but they want a line chart as well.
So, my data is {datetime}, {car-id}. The X -axis of the chart must show the hour of {datetime}, the Y axis the number of cars that entered the park at that hour, and I must have seven data series, lines, one for each day of the week. So, e.g. the x/y point on the green line shows that on Wednesday, at hour x, y cars entered the car park.
Common sense tells me that I can kludge this by transforming the data source so that each day has its own column in a table, a table like this:
DateTime
WeekDay
CarCount
Yet the Crystal line chart doesn't seem to support more than one column, so there must be a different and better way of doing this. The weekday is part of {datetime} after all.
How can I achieve this chart? I am a rank amateur at charting, and Crystal's idiosyncrasies really aggravate my lack of skills and experience in this area.
It's not obvious how to get multiple series to show up properly.
First, create a formula that will extract the day of week from the datetime: dayofweek({datetime}) and then create another that will extract just the hour: hour({datetime}).
From there, insert a chart from scratch and make the following settings in the Chart Expert
Select "Line" under the Type tab
Under the Data tab, select "On change of" and select your {#HourOfDay} formula first. This will create each hour as a point on the X-axis.
In that same spot, also insert the {#DayofWeek} formula. This will create a new line
for each day of the week. This is, in my opinion, the non-obvious part.
Finally, to pick your Y-axis values,
select {car-id} where it says "Show value(s)". It should default to
the count summary of that field.
(Note: in the screenshot below, you would just replace {Customer.Customer_Name} with {car-id}
I had this issue for 5 years and finally solved it. I have a XY chart with multiple series.
Everything needs to be in a formula.
The graph should be in the report header section of a subreport. The sub report generates the X Y data like this:
Series X Y
Ser1 2020 1
Ser1 2021 2
Ser2 2020 0
Ser2 2021 1
For me I have as series "Energy" ie 6, 9, 12 etc.
Then I have a date/time and a measurement.
On change of (Energy formula)
Show Values
#1 DateTime (convert this to int ie 2000.9 for 9/2000) - dont summerize
#2 Measurement (number) - dont' summerize
Then you can do the color highlighter to capture your series (6 is red etc).
The legend won't work - can't figure out that yet.