Friday, March 30, 2012
Report Parameters - Decimal vs. Float
month. In the database, these dates are unfortunately not of type
datetime, but are decimal and are in the YYYYMMDD format.
I'm having trouble getting the report to execute because at the query
level, the datatype has to be decimal. I need to parameterize these
dates, but there is no decimal datatype for parameters.
I have a dataset that generates the necessary dates based on the type
of report the user wants (60/90/120 day) (if they want a 60-day report,
the effective date = 2 months from the first day of the current month,
etc).
SELECT DISTINCT
CONVERT(datetime,LEFT(CAST(effdte AS varchar), 4) + '/' +
SUBSTRING(CAST(effdte AS varchar), 5, 2) + '/' + '01') +
@.period_additive AS effdte_low,
CONVERT(datetime,LEFT(CAST(effdte AS varchar), 4) + '/' +
SUBSTRING(CAST(effdte AS varchar), 5, 2) + '/' + '31') +
@.period_additive AS effdte_high
FROM dbo.t_policy
WHERE YEAR(GETDATE()) - 1 = LEFT(CAST(effdte AS varchar), 4) AND
MONTH(GETDATE()) = SUBSTRING(CAST(effdte AS varchar), 5, 2) AND
LEFT(policy, 3) LIKE @.dept_cd AND LEFT(policy, 3) <> 'LPA'
What would the appropriate code be to do this within the Report
Parameters dialog instead? It seems like I'd have a better chance of
success if it were done that way.
Thanks!
MikeNo matter what, I get this error at runtime (Preview mode):
--
Processing Errors
--
An error has occurred during report processing.
Cannot read the next data row for the data set ds_main.
Arithmetic overflow error converting expression to data type datetime.
--
OK
--|||I think I fixed it...
Even though the database type is decimal, when searching by that range,
I have to put single quotes around it. Therefore, I converted the date
type back to a varchar and changed the parameter data types to string.
Now the report runs.
But there should be a more straightforward way to do this within the
Report Parameters dialog box, shouldn't there?sql
Wednesday, March 21, 2012
Report Model and Aggregates
Once I build a model without selecting "create aggregrates". Can I take that model and change one decimal attribute (PCOM AMT(C2) and make that a numeric aggregate with the additional aggregrate attributes? I tried changint it to "isaggregrate" and then regenerating the attribute but there was no change. Is isaggregrate only used for new expressions?
I get the following message:
The IsAggregate property for the Attribute 'PCOM AMT' is true, but a Column binding is specified. IsAggregate cannot be true if Column is specified.
If I remove binding and rebuild I get this message.
The binding is missing for the Attribute 'PCOM AMT'. Attribute must have exactly one Column binding if Expression is not specified.
Thank you!
IsAggregate flag on entity attribute only tells the model that the attribute can be used as aggregate. Taking a column-bound attribute and marking it IsAggregate will not make it an aggregate.
What you need to do is to leave the column-bound attribute as is and create new attribute that will have an aggregate expression like this: Count(my_column_mound_attribute). Then mark this new attribute as IsAggregate.
Regenerating model will not automatically add new aggregates.
Report Model and Aggregates
Once I build a model without selecting "create aggregrates". Can I take that model and change one decimal attribute (PCOM AMT(C2) and make that a numeric aggregate with the additional aggregrate attributes? I tried changint it to "isaggregrate" and then regenerating the attribute but there was no change. Is isaggregrate only used for new expressions?
I get the following message:
The IsAggregate property for the Attribute 'PCOM AMT' is true, but a Column binding is specified. IsAggregate cannot be true if Column is specified.
If I remove binding and rebuild I get this message.
The binding is missing for the Attribute 'PCOM AMT'. Attribute must have exactly one Column binding if Expression is not specified.
Thank you!
IsAggregate flag on entity attribute only tells the model that the attribute can be used as aggregate. Taking a column-bound attribute and marking it IsAggregate will not make it an aggregate.
What you need to do is to leave the column-bound attribute as is and create new attribute that will have an aggregate expression like this: Count(my_column_mound_attribute). Then mark this new attribute as IsAggregate.
Regenerating model will not automatically add new aggregates.