I have a calculated double Price field in my report that sometimes have a value such as 1.23456.
Each row in my report has these data: Product name followed by Price in parentheses.
=[ProductName] & ' (' & [Price] & ') '
How do I format the Price in the above expression IN THE REPORT DESIGN so that Price always has this format: 1.23? Meaning always having 2 digits after the decimal point.
Thanks. Please note I want to do this at the REPORT DESIGN, not table creation or calculation.
If you go to the Report Design view and right-click on the field that you want to format, open the properties menu.
Under the Format tab on the Properties window, there are 2 options
Format
Decimal Places
You could select Currency or General Number in the Format option and put 2 in the Decimal Places option.
Based on your edit you might be able to do the following, I haven't had a chance to test this.
=[ProductName] & ' (' & FormatNumber([Price], 2) & ') '
Related
I have created a SSRS report. In this report I am using 2 datasets (DataSet1, DataSet2). DataSet1 is the table with all the actual dollar amount charged to the client. Dataset2 is has another dollar amount which is the base amount. Everything is working great except I cannot get the amounts from DataSet2 to have a "$" or 1000 separator. I have already tried making the setting to "currency" and "1000 separator" in the placeholder properties, but that did not work. I think this is due to using 2 datasets. I am using the below expression:
=join(Lookupset(Fields!size_code.Value,Fields!s_size_code.Value,Fields!s_tech_amount.Value, "DataSet2"),",")
I am having difficulty figuring out how to set this number to currency with 1000 separator in the expression for my DataSet2 numbers. The DataSet1 numbers are working perfectly with the currency and 1000 separator that were set in the placeholder properties. Can someone point me in the right direction please?
Your posted expression is returning a string value that consists of the concatenated (join does NOT sum) values of Fields!s_tech_amount from the LookupSet.
The currency formatting can not be applied to a string value.
You can look up how to sum up the values from a LookupSet here.
The currency formatting is only applied to numeric data types.
I have been trying to implement a date range parameter in SSRS 2015. The data is from a cube. I dragged my date into the dimension box of the query designer and went into the parameter tab to change the fromDate and toDate to date/time format and this resulted in the following MDX query.
SELECT ( STRTOMEMBER(#FromDate, CONSTRAINED) :
STRTOMEMBER(#ToDate, CONSTRAINED) )
My date format is dd/mm/yyyy. I have looked on several forums and tried a few method but continued to get the error:
The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function
were violated
Thank you in advance
Your parameters will need to be formed in full address mdx. e.g. #FromDate could be this - I've used the DateKey:
'[Date Dim].[Date Hier].&[20180301]'
So some concatenation, within ssrs, would be required before getting passed:
"[Date Dim].[Date Hier].&[" + 20180301 + "]" //<<you'll need to change to the names used in your cube
I'd also be tempted to use strToSet as you want a set. So mine might be something like:
( STRTOSET( "[Date Dim].[Date Hier].&[" + #FromDate + "]:" +
"[Date Dim].[Date Hier].&[" + #ToDate + "]" , CONSTRAINED) )
Here is a good reference: Range parameter on the MDX-query
The error message you received means that the parameter values do not exist in the cube in that format. To solve this you need to create a field that can be formatted and displayed to users without changing the value that the query uses.
When you create parameters in the Query Designer, it automatically creates hidden datasets which populate the Available Values for the parameter. To see this, right-click on the Datasets folder and select Show Hidden Datasets.
Now, go to the dataset properties and add a calculated field in the Fields tab. This will be your nicely formatted date.
In the parameter properties for each parameter, go to the Available Values tab. Leave the Value field the way it is, but change the Label field to the new column you created.
Now the dropdown will show the friendly label, but use the real value behind the scenes!
I have an Access database with a form that contains a "ProcessTime" field, with the format hh:nn and the input mask 00:00. I've got that part working fine. In the Control Source on the associated table, however, I would like the ProcessTime field/column to appear as decimal minutes. I haven't been able to figure out how to do that.
For example, a user might enter a ProcessTime in the form as 01:30, meaning 1 hour and 30 minutes. I would like the associated value in the table to then appear as 1.5, meaning 1 and a half hours.
How can I go about modifying the ProcessTime field in the table to show the time in decimal hours? I had assumed there would be some simple "decimal time" format I could enter for the ProcessTime field in Design View, but I haven't found one yet.
I'm using MS Access 2013.
There is no intrinsic format or conversion function for this. Don't modify the field. Do a calculation in query or textbox.
[ProcessTime] is a date/time type? The following expression will work for date/time or text type.
Hour([ProcessTime]) + Minute([ProcessTime])/60
If the textbox is bound to the field, it will be problematic to make a conversion like that as you will have different data types (date/time and decimal). If it is not a bound textbox you can split the textbox value on the colon (:) and then concatenate hours & (minutes/60) and then write the information to the table.
Dim temp as string
temp = split(ProcessTime.Value,":")
currentDB.Execute "Update <table name> SET ProcessTime=" & temp(0) & temp(1)/60 & "WHERE <condition>;"
'Or you are adding a new record you can do an Insert Query
' Replace the Update statement above with "INSERT INTO <table name> (<other fields>,ProcessTime) VALUES (<other values>," & temp(0) & temp(1)/60 & ");"
Hello please can anyone assist
I have 2 datasets, one of them is filtered to bring back a set of numbers.
I have another dataset using the same data source which is filtered to bring back a different set of numbers.
I want to look up from one dataset to the other to have both sets of figures in the same matrix.
The Matrix is setup to have a name in a row, and month date in the colum.
I want to therefore look up the name from the 2nd dataset as well as the month number and return the value into the above.
Is there anyway to lookup against 2 conditions and return the value ?
Thanks !
Yes - you can combine the fields into one using a separator between the fields.
=Lookup(Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!Number.Value, "Product")
The separator is used to keep values from the first field affecting values from the second.
Update:
For your issue when there is no month, you can try excluding them:
=IIF(ISNOTHING(Fields!MonthNum.Value), NOTHING,
Lookup(Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!Number.Value, "Product") )
If MonthNum is NULL, it will return NULL (Nothing in SSRS).
I would like to iterate over the rows in my Payment table. User chose for what month and year has wants to book and I want to check in the each raw if this house was booked for this year and month. I want to compare if
HouseID == chosenHouseID && BookingMonth == chosenBookingMonth &&
BookingYear==chosenBookingYear.
If this is true it should pop out message box with info that house was already booked for this month. Also if user chose more than one month i.e. numMonths would be 3, it should increment value of the month (which is a text) it should go to the next value (if there is no next value then it should do mod 12) and do the checking again. Maybe it will be necessary to switch data type of BookingMonth to numeric?
However I hope I was clear what I want to do. I have experience with Java, C, Python and Visual Basic, but I did not do much in Access so it is quite confusing. I could not find the any useful info how to perform this operation. Please advise me on my issue.
Thank you
Yes, you definitely should store the [BookingMonth] as numeric. Maintaining a "month" column as text will be a nuisance in the long run, since "August"<"January" and "12"<"2". You'd have to do at least a certain amount of juggling to convert the text values to numeric values, so make like easy for yourself and just maintain them as numeric. (Note that you can always format them as text if you want to use them in reports.)
As for your search requirements, if the user supplies a [chosenBookingYear], [chosenBookingMonth], and [numberOfMonthsToBook] then you can use the VBA DateAdd function to derive [endOfBookingYear] and [endOfBookingMonth] safely, accounting for "next year" values...
endOfBookingYear = Year(DateAdd("m", numberOfMonthsToBook - 1, DateSerial(chosenBookingYear, chosenBookingMonth, 1)))
...and...
endOfBookingMonth = Month(DateAdd("m", numberOfMonthsToBook - 1, DateSerial(chosenBookingYear, chosenBookingMonth, 1)))
Finally, to perform the lookup without looping through individual rows you can concatenate [BookingYear] and [BookingMonth] together to create something like "2013/05" using...
BookingYear & "/" & Format(BookingMonth, "00")
...so then you can create a SELECT query something like this:
SELECT * FROM Payment
WHERE HouseID = chosenHouseID AND
(
(BookingYear & "/" & Format(BookingMonth, "00"))
BETWEEN (chosenBookingYear & "/" & Format(chosenBookingMonth, "00"))
AND (endOfBookingYear & "/" & Format(endOfBookingMonth, "00"))
)