How to setup custom number format for Year and isoweeknumber like "YY'WW" - ssrs-2008

I have below problem. I am putting below function in my custom number format for x axis of chart. It works for Years and Mohths but when I choose Weeks, then it is changing my date into YY'WW (Year'Week) format.
Can you please help me on this, if you have an idea?
you need to change only in Parameters!vTimeScaleUnit.Value="Weeks","yy'WW" code.
=switch(Parameters!vTimeScaleUnit.Value="Years","yyyy",Parameters!vTimeScaleUnit.Value="Months","MM"&"/"&"yy",Parameters!vTimeScaleUnit.Value="Weeks","yy'WW")

Related

Time series visualization with status update for multiple attributes

Below is the sample data. I Need to plot a chart to visualize status changes for multiple attributes over a period of time. Below are the additional points the visualization should handle. I am not looking for any specific charting solution to implement the visualization but rather get an idea of how this can be handled.
In the below data, there are three attributes(r1,r2,r3), but I could have up to 30.
For each attribute, the status can be Pass/Fail/Error for a given month (period).
There could be as many as 100 months of data to plot.
Request,Date,Status
r1,Jan, Pass
r2,Jan, Pass
r3,Jan, Fail
r1,Feb, Pass
r2,Feb, Fail
r3,Feb, Pass
r1,Mar, Pass
r2,Mar, Error
r3,Mar, Pass
r1,Apr, Pass
r2,Apr, Error
r3,Apr, Fail
r1,r2,r3 are student results each month.
You could use a line/bar plot :
code Pass/Fail/Error with 0,1,2 and plot it on y axis,
on x axis put R1/R2/R3 stacked with date, even if you have 100 months
you have to put a switch where you can choose the month
By the way your question is too vague...what are R1,R2,R3? it seems that is something that must be put in production

matplotlib plot_date() add vertical line at specified date

My data is stored as a pandas dataframe. I have created a chart of date (object format) vs. percentile (int64 format) using the plot_date() function in matplotlib and would like to add some vertical lines at pre-specified dates.
I have managed to add point markers at the pre-specified dates, but can't seem to find a way to make them into vertical lines.
I've found various answers on SO/SE about how to add vertical lines to a plot(), but am having trouble converting my data to a format that can be used by plot(), hence why I have used plot_date().
Sample data:
date percentile
2012-05-30 3
2014-11-25 60
2012-06-15 38
2013-07-18 16
My code to plot the chart is as below:
x_data = data["date"]
y_data = data["percentile"]
plt.figure()
plt.plot()
#create a scatter chart of dates vs. percentile
plt.plot_date(x = x_data, y = y_data)
#now add a marker at prespecified dates - ideally this would be a vertical line
plt.plot_date(x = '2012-09-21', y = 0)
plt.savefig("percentile_plot.png")
plt.close()
Unfortunately I can't provide an image of the current output as the code is on a terminal with no web access.
Any help is greatly appreciated - also in terms of how I've asked the question as I am quite new to SO / SE.
Thank you.
In MatPlotLib 1.4.3 this works:
import datetime as dt
plt.axvline(dt.datetime(2012, 9, 21))
Passing a string-style date (2012-09-21) doesn't work because MPL doesn't know this is a date. Whatever code you are using to load your file is probably implicitly creating datetime objects out of your strings, which is why the plot call works.
Also, in MPL 1.4.3, I did not need to call plt.plot_date(data['date'], ...), simply calling plt.plot(data['date'], ...) worked for me as long as the data['date'] column is a column of datetime objects.
Good luck.
Use pandas. Here is an example, also converting to timestamps just in case:
df = pd.DataFrame({
'date':[
'2012-05-30',
'2014-11-25',
'2012-06-15',
'2013-07-18',
],
'percentile':[3,60,38,16]
})
df['date'] = df['date'].apply(pd.Timestamp)
df=df.set_index('date')
df.plot(marker='o')
plt.axvline(pd.Timestamp('2013-09-21'),color='r')
Here is the output:

Converting from datenum back to actual time

Ok, so I've been messing with what should be a simple problem. I'm trying to plot an numerical array (double) vs. the associated time stamp (cell) with the format of the DD-MM-YY HH:MM:SS (for example: 13-Mar-15 07:23:10).
I'm able to plot a single set using datetime(time stamp). Due to the data set it outputs the nice HH:MM on the x-axis. Very nice.
Now in order to plot 2 sets of values on the same graph, I've found that Matlab doesn't like to use the date_time twice for the x-axis, so then I go to the infamous datenum function, which is able to plot both on the same graph. However, it's in the serial value of time and it jacks with my plot sizing (i.e. the x-axis doesn't autosize).
With what should be a simple problem has actually caused me days scouring the internet trying to reconvert it back to my beloved HH:MM after converting the "time stamp" into the serial time.
I don't think that a code sample or data set should be necessary for example purposes. (but can provide if needed)
I've tried to use the datetick function, but can't get seem to get it working.
The trick with datenum and datetick is to set limits and tick positions before you call datetick, then make sure it doesn't redo them.
So, after plotting your two sets of data against the datenums it would go something like:
step = 1/24; % for hourly - adjust to preference
ticks = datenum('mystarttime'):step:datenum('myendtime')
set(gca,'XTick',ticks)
datetick('x','HH:MM','keepticks','keeplimits')
I work a lot with time series and most often I have to plot my data versus time/date.
Since Matlab never gave me a definitively convenient solution, for many years now I work this way:
I defined once and for all a Matlab shortcut (in the matlab shortcut toolbar):
containing the following code:
xticktemp = get(gca,'Xtick') ;
ticklabel = {datestr(xticktemp(1)) datestr(xticktemp(2:end),15) } ;
set(gca,'Xticklabel',ticklabel)
clear xticktemp ticklabel
I convert all my times with datenum and use this format for working (or posix time when more convenient, but it's another story), calculating and plotting. When I need to now exactly the time of an event in a human readable format, I press the shortcut and I obtain something like:
Of course there are 2 major limitations with this method:
This does not control the steps of the ticks (it just replicate what Matlab initially set)
You have to re-click your shortcut to refresh the tick labels everytime you zoom or pan the figure
For these reasons, when I need to finalize figure for presentation to others I won't use this trick and define my ticks exactly like I want them, but when you are simply working away, this shortcut has saved me hours (may be even days?) of fiddling around over the last 10 years ....

Converting time 1am to 1pm in matlab

I have a dateset in excel which store date in the following format
12:59
1:00
when it's read into matlab, it's represented
0.5410
0.0417
This has caused incorrect graph plotting. I realize that the second input should be 13:00, instead of 1:00. How can I pre-process this info in matlab before plotting graph, to be exact, what is the value which represent, 13:00 to 23:59 ? How can I check it in matlab?
It looks like your import from Excel has brought it in as a serial Date number
I think you need to have a look at how your importing dates from Excel. It can be problematic due to the differing ways Excel and Matlab handle dates. Have a look at this link
I expect your also going to need to use the DateStr function
For example converting the time 01:00 pm in it's 12-hour format to a 24-hour format.
datestr('01:00 PM','HH:MM')
Edit:
Or alternativley
Look at addtodate().
addtodate(0.0417,12,'hour')
This should add 12 hours to your 01:00 making it 13:00.
As you know that all afternoon work is before 6, and no morning work is done before 6, it is really easy to fix with postprocessing:
For example like this:
x = [0.5410 0.0417];
idx = x<=6/24; %Or use 7 for example if you want to be more safe
x(idx) = x(idx)+0.5
Note that if your excel file actually does contain the AM-PM information, you may prefer to go for preprocessing instead. (Just incase people work outside office hours).
As a workaround you might try the following conversion, starting from time array tim in the range 0-1:
tim2 = tim*24;
ar = zeros(1,length(tim2));
ar(diff([0 tim2])<0) = 1;
tim2 = (cumsum(ar)*12 + tim2)/24;
Make sure to test it especially on the times 12pm-1am and 12am-1pm

Is it possible to show numbers in non-engineering format in MATLAB?

I have some large floating point numbers such as 1243564832.75 in MATLAB. MATLAB changes the format to 1.2435e09 or if I use long format: 1.2435648e09 or something like that.
Is there any way I can display the numbers in their non-engineering format (1243564832.75)?
Call the following command
format longG
Then the display should be "fixed"