Link to home
Start Free TrialLog in
Avatar of syamsundar
syamsundar

asked on

How to use @prompt in choosing dynamic parameters

it looks like user wants to dynamically show data between two dates or two weeks or two months something like that.

I have created the objects and in the webi and made where conditions equal to those objects but been getting nothing but errors.

Below is the code, hope the explanation is clear enough
--FirstDayOfMonth
CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-' + 
CASE WHEN MONTH(GETDATE())<10 THEN '0' ELSE ' END + 
CAST(MONTH(GETDATE()) AS VARCHAR(2)) + '-01 00:00:00.001' 
 
--LastDayOfMonth
DATEADD(day,
-1,
CAST(YEAR(DATEADD(month,1,GETDATE())) AS VARCHAR(4)) + '-' + 
CASE WHEN MONTH(DATEADD(month,1,GETDATE()))<10 THEN '0' ELSE ' END + 
CAST(MONTH(DATEADD(month,1,GETDATE())) AS VARCHAR(2)) + '-01 23:59:59.998'
) 
 
 
--Prompt for Periodicity
@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
 
 
--So the FirstPeriod object would be defined as
DATEADD(@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
,@prompt('Num1Begin','N',,Mono,Free,Persistent), CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-' +  CASE WHEN MONTH(GETDATE())<10 THEN '0' ELSE ' END + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + '-01 00:00:00.001')
 
--And the EndOfPeriod object would be defined as
DATEADD(@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
,@prompt('Num1End','N',,Mono,Free,Persistent), DATEADD(day,-1,CAST(YEAR(DATEADD(month,1,GETDATE())) AS VARCHAR(4)) + '-' + CASE WHEN MONTH(DATEADD(month,1,GETDATE()))<10 THEN '0' ELSE ' END + CAST(MONTH(DATEADD(month,1,GETDATE())) AS VARCHAR(2)) + '-01 23:59:59.998'))

Open in new window

Avatar of wykabryan
wykabryan
Flag of United States of America image

you can not use an @prompt as a dynamic. Dynamic parameters can only be used on the actual webi document.
Avatar of syamsundar
syamsundar

ASKER

its not true we can use @prompt in universe designer, we have lot of them
ASKER CERTIFIED SOLUTION
Avatar of wykabryan
wykabryan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial