Wanted to know if this can be done. # weeks b/w months.

Hi Gurus,

I wanted to know, if this is possible to be calculated at report level only. I don’t have access to universe or database. I am using Deski XI against Oracle.

In one of my DP i pull historical 6 months data. If current month is Feb, 2009 i get data from August, 2008 to Jan, 2009. User would select these 2 values in prompts.

Using UserResponce() functions and other date function can i calculate the number of weeks between these 2 months.

I have months available in 3 different formats.

[b]Format 1:

Accounting Period Desc = 1, 2, 3, 4...., 10, 11, 12

[/b]

[b]Format 2:

Accounting Period = 2008, AP11, 2008 AP12, 2009 AP01, 2009 AP02.... 2009 AP12.

[/b]

[b]Format 3:

AP Desc = AP01, AP02, AP03,... AP11, AP12

[/b]

I need the number that tells me the number of weeks between the selected months. I am currently using Format 2 in the prompts in my report (obviouslly :wink: ).

Need help!!!

Thanks in advance.


boe_bods :india: (BOB member since 2008-03-14)

Try this.

=Week(date2) - Week(date1) 

P.S: As UserResponse() returns string, first convert it to date and then go for the above code.


Jansi :india: (BOB member since 2008-05-12)

Jansi,

Would you be more precise as to how we can go about changing a User Response() string output to a date. And if we are able to convert it to a date what date would that be. Will it make sure that it converts it the start date of the month i.e “date 1”.

Kindly, help in converting the User Response Month to date.

Thank again!!!


boe_bods :india: (BOB member since 2008-03-14)

Could you please give us what you select/enter in your prompt? i.e. the exact format?

P.S: To convert a UserResponse string to a date type, use ToDate() function.


Jansi :india: (BOB member since 2008-05-12)

Jansi,

Yes i tried using Todate() function to convert the User entered value, but could not figure it out.

The prompt is on month. As i have said earlier, the Month format is YYYY APMM i.e 2009 AP01 for Jan, 2009.

The report would have 2 prompts.(if current month is 2009 AP08 user would pick 2009 AP02 and 2009 AP07 in prompts)

[b]Enter 6th Month Prior to Previous Month:

2009 AP02

[/b]

[b]Enter Previous Month:

2009 AP07

[/b]

Does this explain my scenario. Thanks.


boe_bods :india: (BOB member since 2008-03-14)

PW=Week(ToDate(Concatenation(Replace(UserResponse("Enter 6th Month Prior to Previous Month:")," AP",""),"01"),"YYYYMMDD"))
LW=Week(ToDate(Concatenation(Replace(UserResponse("Enter Previous Month:")," AP",""),"01"),"YYYYMMDD"))
NOW=<PW>-<LW>

Does that help?


Jansi :india: (BOB member since 2008-05-12)

Jansi,

This is what was the final formula that i had created in my report and i was expecting it to work but its returning #ERROR message. Here are the details objects that were created at report level.

LW:

=Week(ToDate(Concatenation(Replace(UserResponse("6 Months" ,"4. Enter 6th month prior to previous month:") ," AP" ,"") ,"01") ,"yyyymmdd"))

PW:

=Week(ToDate(Concatenation(Replace(UserResponse("6 Months" ,"5. Enter Previous Month:") ," AP" ,"") ,"01") ,"yyyymmdd"))

Both of these objects return #ERROR message and hence the NOW variable too has #ERROR. Made changes to the UserResponce() to what you had provided by pointing the data provider that needs to be used from the report.

Any idea whats going wrong?


boe_bods :india: (BOB member since 2008-03-14)

Please try splitting up the code into smaller ones and test them out. I would suggest you to especially check ToDate() part. Are you sure the date format of the prompt value is YYYY APMM? When I tried it out here, I’m able to bring the result. :?


Jansi :india: (BOB member since 2008-05-12)

:hb: :reallymad: my mistake. The Prompt format is FYYYYY APMM.

Their is “FY” prefix to YYYY. Their were whole bunch of other changes that is taking toal on me :crazy_face: on this report. I would really appreciate if you can help me in getting the updated formula for PW.

Thanks.


boe_bods :india: (BOB member since 2008-03-14)

Same. Again replace FY by “”.

pw=Week(ToDate(Concatenation(Replace(Replace(UserResponse("6 Months" ,"4. Enter 6th month prior to previous month:") ," AP" ,""),"FY","") ,"01") ,"yyyymmdd"))
lw=Week(ToDate(Concatenation(Replace(Replace(UserResponse("6 Months" ,"5. Enter Previous Month:") ," AP" ,""),"FY","") ,"01") ,"yyyymmdd"))

Jansi :india: (BOB member since 2008-05-12)

Jansi,

Don’t know whats going on now. Tried removing all the replace and other functions and tried seeing the character that would be returned by using UserResponce() function and it still returns #ERROR. Please see below.

=UserResponse("6 Months" ,"4. Enter 6th month prior to previous month:")

I even tried

=UserResponse(DataProvider(<Accounting Period(6 Months)>) ,"4. Enter 6th month prior to previous month:")

Why does it not return the value that was entered in the prompt. :frowning: . Please!


boe_bods :india: (BOB member since 2008-03-14)

Okay, the last try. Try this. Go to Insert (from the menu bar) -> Special Field -> Query prompt -> Select any one of the query prompt and see what formula is getting generated.


Jansi :india: (BOB member since 2008-05-12)

Jansi,

The formula is similar to what we are generating. Just copied that UserResponce() and placed it in a Detail variable at report level and it is giving me the values that we need i.e FY2009 AP02 for 6 months prior to previous month and FY2009 AP07 for Previous Month. This is fine.

Now after doing that when i try to do replace() function for FY text it is not returning the new value which should have been “2009 AP02” rather shows me the same value i.e “FY2009 AP02”.

Here’s the partial formula that i tried:

=Replace(UserResponse ("6 Months" , "4. Enter 6th month prior to previous month:") ,"FY" ,"")

This is returning FY2009 AP02 only, which is strange as was the earlier case. :frowning:


boe_bods :india: (BOB member since 2008-03-14)

That shouldn’t be. :? Try replacing AP by “” and see whether this has any effect.


Jansi :india: (BOB member since 2008-05-12)

It works great!!! :smiley: :smiley: . Still dont get the result that i am getting when i define a variable. Dosen’t that sound strange that if i do the same calculation as if its a formula it returns me the result, but if i do it by defining a variable it just gives me the UserResponce() function results.

Got the result at-last that i am looking for. Just wondering y is it not returning me the result when i define a variable?:shock:

Thanks a million Jansi for all your help and support.


boe_bods :india: (BOB member since 2008-03-14)

Glad it worked at last. But still mystery remains. :wink:

Moderator Note: Please do not use Instant Message abbreviations on BOB. We want to keep BOB easy to understand for our International community. Thanks.


Jansi :india: (BOB member since 2008-05-12)