Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I establish a Variable

Status
Not open for further replies.

PruSQLer

Technical User
Nov 6, 2001
221
US
I'm new to BO and here's my problem: I need to make calculations based on a date passed to the query by the person creating the report. Is there a way to establish a Variable right at the start? I know @Prompt can be used to elicit user criteria but I need to use the date many times in the calculations and I sense I'd need to prompt for the date each time. What's the best way to handle this?
 
confused.....

You can prompt 1 time for a date. Then you can create a variable on the report using the UserResponse function. Now you have a variable that you can use and reuse for all your calculations. Steve Krandel
BASE Consulting Group
 
You're confused? Try being me.

Anyway, I wound up doing the below code. It just seemed to me there must be another way to do this where you didn't have to type in the @Prompt every time you need the date, like in VB where you get the user input and then just use that in your code. But, this works...

sum(decimal(prv_amt_unit * decimal( decimal( double(days(@prompt('Enter the EOP Date','D','TimeParameters\EOP_Date',Mono,constrained)) -
days( case when month(gnrc_dt) <= month ( @prompt('Enter the EOP Date','D','TimeParameters\EOP_Date',Mono,constrained) )
and year(gnrc_dt) = year(@prompt('Enter the EOP Date','D','TimeParameters\EOP_Date',Mono,constrained))
then '2002-03-31'
else
case when year(gnrc_dt) = 2002
then @prompt('Enter the EOP Date','D','TimeParameters\EOP_Date',Mono,constrained)
else rtrim(char(year(@prompt('Enter the EOP Date','D','TimeParameters\EOP_Date',Mono,constrained)))) || '-01-01'
end
end
) ) /365.0 * 0.035
,7,5) ,7,5) ,11,2) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top