If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

how to calculate previous ytd[SOLVED]

Started by inu, 10 Mar 2014 05:29:43 AM

Previous topic - Next topic

inu

Hi
Please guys tell me how to calculate the Previous ytd.Please mention the code. i m getting error

Thaks
Inam

BigChris

What code are you using and what error are you getting? Relational or dimensional? SQL server / Oracle / Something else?

Give us a clue and we might be able to help...

MFGF

Quote from: inamulhaque on 10 Mar 2014 05:29:43 AM
Hi
Please guys tell me how to calculate the Previous ytd.Please mention the code. i m getting error

Thaks
Inam

Hi,

Please read Paragraph 1 and give us the relevant info:

http://www.cognoise.com/index.php/topic,24030.0.html

Thanks,

MF.
Meep!

inu

HI
I have written the code which is wrong. I wanted to know the correct syntax,,, that's it bro.

case when [order_date] between 2013-01-01 and current_date-1 then Amount_sold end

I know this is wrong syntax, I want to know the correct one. Can you please rectify it.
                OR
Any other way to avoid writing these code stuffs. How to find the ytd dynamically instead of hard coding.

Thanks and Regards
Inam

MFGF

Hi,

What error do you get? Is it a relational package or dimensional? List or crosstab/chart? Why do you seem so reluctant to provide even the most basic of information about what your situation is? We are not sitting looking over your shoulder so how can we be expected to know what your report is doing and how it's written?

I'm going to make some assumptions because you still haven't given us this information...

Assuming it's relational, and that [order_date] is a date datatype, and that you want the Amount_sold value just in the current year (2014)

Try this:
case extract(year,[order_date])
when extract(year,current_date) then [Amount_sold]
else 0
end

Or you could filter the query with an expression such as extract(year,[order_date]) = extract(year,current_date]) and display just the Amount_sold measure

MF.
Meep!

inu

Hi
First of all , I m using relational model, list report.
Exactly what you have given me the code for the current ytd. I want to get the previous ytd. But I don't know how to get it.
Please give me the code, I m not getting in the google.

Regards
Inam

MFGF

Quote from: inamulhaque on 13 Mar 2014 06:01:21 AM
Hi
First of all , I m using relational model, list report.
Exactly what you have given me the code for the current ytd. I want to get the previous ytd. But I don't know how to get it.
Please give me the code, I m not getting in the google.

Regards
Inam

Ok. In that case you need the dates from the beginning of last year up to the date corresponding to a year ago today...

The starting date is the beginning of the year. We get this by using a _make_timestamp() function, specifying the year, month and day values. The year value is obtained by extracting the year from today's date using the extract() function, then subtracting 1 from the result, and the month and day parts are both 1. This would return a result of 1st January 2013 if you were to evaluate it now.
The ending date is the date exactly one year ago. We get this by using the _add_years() function and today's date, adding -1 years. This would return a result of 13th March 2013 if you were to evaluate it now.

case when [order_date] between _make_timestamp (extract(year,current_date) -1, 1, 1) and _add_years(current_date, -1)
then [Amount_sold]
else 0
end

If you had explained your requirement, your environment and your issues clearly in the first post rather than posting simply "tell me how to calculate the Previous ytd.Please mention the code. i m getting error" We could have sent this answer straignt back to you. As it is, it has taken three days to get to this point. I hope you can see that spending a little time and effort on explaining your requirements initially can save you a huge amount of time in the long run?

Cheers!

MF.
Meep!