No, there are no NULLs involved
Removing the Format string shows the TimeSpan using the default "c" format, so it is a definitely a TimeSpan object.
So, I have a report. The report contains a chart, and a Tablix list.
For the "Value" in the data source I have a TimeSpan.
In the chart, the Value is "=TimeSpan.FromTicks(Avg(Fields!Value.Value)))"
The Vertical Axis Property Number is set to "Custom" "HH:mm:ss"
Both the Vertical Axis, and the Data Labels show (for example) 00:07:13
I also have a Tablix, with a column that has at the Group and Total levels, a cell with "=TimeSpan.FromTicks(Avg(Fields!Value.Value)))"
With Number set to "Default", they both show (for example) 00:07:13.1234567, which is the "ToString" default.
If I set Number to "Custom" "HH:mm:ss", or to "Time", or I set the cell to "=TimeSpan.FromTicks(Avg(Fields!Value.Value))).ToString("HH:mm:ss")", or "=TimeSpan.FromTicks(Avg(Fields!Value.Value))).ToString("HH:mm:ss")", it renders as "#Error"
Any suggestions as to what's wrong here?
EDIT: hh\:mm\:ss works (lowercase H)
And it seems the answer is that the Chart will "somehow" allow a TimeSpan to understand the formatting specifiers for DateTime, where a Tablix formatter does not.
So, the Chart will treat HH:mm:ss as the same as "hh\:mm\:ss", where only the latter is a valid format for TimeSpan.
Related
I am exporting a report to Excel from Access through VBA. There is a column in the report that should be formatted as percentage and round. How can I format this?
Set the Format property of the textbox in the report to: Percent
You may have to divide the value by 100 first. If so, rename the textbox to anything else than the name of the field, and use this expression as ControlSource:
=[YourFieldName]/100
For a new formatted string value, use Format:
=Format([YourFieldName],"Percent")
You don't mention what kind of rounding you need, but functions for all general methods of rounding are listed here: Rounding values up, down, by 4/5, or to significant figures
I am trying to dynamically format the labels on my SSRS charts based on the underlying value. I'm trying to do this in two scenarios, one to format dates as ordinals and another to choose the appropriate number of decimal places based on actual values present. However, when I use the expression editor with an expression something like this...
=IIF(MAX(ABS(Fields![axisfield].Value))<2, "0.0%","0%")
...the Fields![axisfield].Value is always returning the first value from the dataset, meaning, in this example, if the first value is less than two, the labels will be formatted with one decimal place, even if it is the only one less than two. (So the 'MAX' function is essentially irrelevant.)
That example is attempting to set the overall formatting based on the largest data point in the series, in this next one I'm trying to format each label separately to get Ordinal dates (i.e. 1st, 2nd, etc, and yes, this formula is incomplete: it doesn't need to be to illustrate the problem):
="dd"+IIF(DatePart("d", Fields!date.Value)=1,"\s\t"
,IIF(DatePart("d", Fields!date.Value)=2,"\n\d"
,IIF(DatePart("d", Fields!date.Value)=3,"\r\d"
,"\t\h")))
This will give 1st, 2st, 3st and so on, as the first row in the dataset is for the first.
So, my question is, how do I get round this and, in the first example get the true maximum, and in the second reference the actual value being formatted?
Thanks!
I've had the same issues with using custom functions for setting label visibility. (see my entry for this: How to Display Only 1 Value Label in SSRS 2012 Calculated/Derived Series? )
I believe the issue is that data and fields are bound to the underlying data series but are not bound and accessible within the label itself.
You should be able to set the formatting in the function for the series data itself (as in the 2nd example) and then just set data labels, which will use the underlying series field value. An example with your data might be something like the following, which returns the values with the format:
="dd"+IIF(DatePart("d", Fields!date.Value)=1,Format(Fields!date.Value, "\s\t")
,IIF(DatePart("d", Fields!date.Value)=2,Format(Fields!date.Value,"\n\d")
,IIF(DatePart("d", Fields!date.Value)=3,Format(Fields!date.Value, "\r\d")
,Format(Fields!date.Value,"\t\h"))))
In the first example, you can get the max value to referring to the Dataset, as opposed to the field. Your code would then be:
=IIF(ABS(MAX(Fields![axisfield].Value, "YourDatasetName"))<2, "0.0%","0%")
(I changed the order of operations for Abs and Max because you have to use an aggregate function when referring to the whole dataset. Only then can you refer to the specific value.)
Currently I am working on a ssrs report. The table in report is having about 30 columns. For each column I have to modify the number format (to either 2 decimal or no decimal numbers). I can do it by click on every column and modify the number property in format menu. But is there any way to format all the columns at a time?
I tried to select entire row -> F4 -> properties -> Number -> Format-> Expression. And set expression to:
=FormatNumber(Fields!HoursWorked.Value&Fields!ContactAttempted.Value&Fields!UnableToContact.Value,2)
But it throws an error
Type character '&' does not match declared data type 'Object'.
Can any one help me on this?
This is really, really stupid; you have to have spaces before and after the ampersand, and if you don't then you tend to get that error message. I don't know why, it's daft as hell but I bet that's it. Catches me out constantly. Try:
=FormatNumber(Fields!HoursWorked.Value & Fields!ContactAttempted.Value & Fields!UnableToContact.Value,2)
If you want to set the Format property of a cell (or cells - note you CAN set the format for multiple cells at the same time) then you need to specify a value or expression that resolves to a recognised format string, e.g. '$'0,.00;'$'-0,.00 or C2.
The expression you have given returns the actual formatted value of the cell, so this will not work if entered into the Format property - this needs to go in the Value property of the textbox.
You need to set format number for each column separately. If you don't want to set number format in Text Box Properties, you can set format such way:
Click on cell with value -> F4 -> field Format in Properties -> set format (for example, you can use this format: #,0.00 for numbers with space as 1000 separator and negative numbers as -12 345.00)
I need to make it so that the one field either displays the Date or the value of 0. They're two separate formats, and so I can't get Access to mix the two up. Logic functions keep displaying errors for me.
You can do conditional formatting like so as a "custom" format:
[=0] 0; [>0] mm/dd/yyyy;
[=0] checks if the value is zero, if so, the cell is set to 0. If it is greater than 0, use mm/dd/yyyy or whatever date format you like.
You can use Format. Rename your textbox to be different from the date field name and this as ControlSource:
=Format([YourDateField],IIf([YourDateField]=0,"0","yyyy-mm-dd"))
My problem is concerning a chart in reporting services.
My dataset is looking as below:
MonthDue MonthDeleviry
Jan-2011 Mars-2011
Feb-2012 Jun_2013
Aug-2016 Oct-014
I want to make a graphique MonthDue(Y-axis) /.MonthDeleviry(X-axis) the problem is that Y-axis doesen't show label of month and convert it to FirstDayMonth/MM/YYYY. It seems that this axis dont accepte String value and allow just Numeric and date Format (dd/mm/YYYY)
Excuse my bad english
Can you help please.
Thanks
If the Y axis accepts a datetime but your data is a string of the format given, you could convert that string into a datetime for the start of that month.
=cdate("1-" & Fields!MonthDue)
Use this expression in the "Value" field of the "Values" tab when you edit the data in the chart properties.
Hope that helps.