Using UserResponse function in reports gives error

Hi everybody,

I am having trouble getting this code to work.

I have the query questions “1, Year 1 :” and “2, Year 2 :” I want to use to address the years I want the data for from Measures v_NumberBlocks.

The variabel editor is:
=([v_NumberofBlocks] Where ([Year]=(UserResponse(“1, Year 1 :”)))/[v_NumberofBlocks] Where ([Jaar]=(UserResponse(“2, Year 2 :”)))*100)

I get the error

The expression or sub-expression at position 35 in the ‘=’ function uses an invalid data type.

Can anybody help me out?

Thanks in advance.


alirsf :netherlands: (BOB member since 2010-06-15)

Tell me datatype of [Year] and [Jaar] objects.


pravin_gaikwad :india: (BOB member since 2010-03-27)

What do you mean by Datatype?

They both represent a 4 digit indication of years; i.e. 2006, 2007, 2010, etc.

Is that what you mean Pravin?

Gr,

alirsf


alirsf :netherlands: (BOB member since 2010-06-15)

I am interrested to know whether that are number, char or date fields.

Because UserResponse fuction take userinput as char format.
If Your objects are number then You need to convert input value to number. By using ToNumber() function.


pravin_gaikwad :india: (BOB member since 2010-03-27)

Thanks for your quick response, but I have a user query Prompt asking for year 1 and Jaar 2. I want the User Responses to these queries to be filtered for the years in the BO document.

And I do not understand how to apply the ToNumber() function in my code:

=([v_NumberofBlocks] Where ([Year]=(UserResponse(“1, Year 1 :”)))/[v_NumberofBlocks] Where ([Jaar]=(UserResponse(“2, Year 2 :”)))*100)

And yes they are date fields.


alirsf :netherlands: (BOB member since 2010-06-15)

[Moderator Note: Moving from SDK to Web Intelligence - MichaelWelter]


MichaelWelter :vatican_city: (BOB member since 2002-08-08)

hi,

Please try the following syntax,

=([v_NumberofBlocks] Where ([Year]=(tonumber(UserResponse("1, Year 1 :")))/[v_NumberofBlocks] Where ([Jaar]=(tonumber(UserResponse("2, Year 2 :"))))*100)

[Moderator Edit: Added code formatting - Jansi] When posting code samples please use the code option for formatting. It will preserve any indenting or formatting that you may have done.


pravin_gaikwad :india: (BOB member since 2010-03-27)

Thanks for your reply Pravin, I think we’re almost there:

I made the code less sophisticated;

=([v_NumberofBlocks] Where ([Year]=2009))/[v_NumberofBlocks] Where ([Jaar]=2010)*100

And it works…

But I want the report to be dynamic and use the entries from the user, hence the desire to use the UserResponse function. What are we missing here?


alirsf :netherlands: (BOB member since 2010-06-15)

Hi,

If you give value for [Year], [Jaar] object as number Its working that is these two objects datatypes are number.

So try to convert userinput to number by using ToNumber() function, I think it will work.

also tell me what about my previous syntax. u tried or not ???


pravin_gaikwad :india: (BOB member since 2010-03-27)

=[v_NumberofBlocks]Where([Year] =(ToNumber(UserResponse(“1, Year 1 :”))))/[v_NumberofBlocks]Where([Year] =(ToNumber(UserResponse(“2, Year 2 :”))))*100

This is the code I used, and it is pretty much the same as you suggested, right? So yes, it works.

I had to convert some of the names of objects and translate things for this forum because of disclosure issues. But your syntax works, thank you for your time and help!

Regards,

Alirsf


alirsf :netherlands: (BOB member since 2010-06-15)