cancel
Showing results for 
Search instead for 
Did you mean: 

YTD Calculation

former_member203645
Active Participant
0 Kudos

Hi all,

How can I calculate YTD from Sybase IQ, In BO I am trying to calculate this :

I have code for oracle , Please help

I need the below as date because in BO , I will pull the start date as this object and end date the user will enter,

SUM

(

   CASE WHEN (Sometable.Fact_Date) between TRUNC (sysdate , 'yyyy') and sysdate

      THEN FactTable.Measure

   END

)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I’m not clear about your question, but if you what a sum for
a fact mesure for the YTD, you only need

select sum (fact_mesure)

  from DBA.fact_table

where year(fact_date) = year(getdate()) 

Hope this help.

former_member203645
Active Participant
0 Kudos

In Business Objects, I have a date filter with Start date and End date.

Based on the End date , the start date should start 01/01/XXXX.

XXXX is the Year of the end date.

Below is something I did for First of the quarter, I need the same way for the Year.

I added the below code for Start date and End date will prompt for the user.


cast( (  CASE WHEN QUARTER(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)=1 THEN   trim(Convert(varchar(20),Year(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE))) + '-01-01'

         WHEN QUARTER(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)=2 THEN   trim(Convert(varchar(20),Year(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)) ) + '-04-01'

         WHEN QUARTER(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)=3 THEN   trim(Convert(varchar(20),Year(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)) ) + '-07-01'

         WHEN QUARTER(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)=4 THEN   trim(Convert(varchar(20),Year(RGH.FACTPAYROLL_V.PAYROLLPAIDDATE)) ) + '-10-01'

END

) as date)

Former Member
0 Kudos

select cast(cast(year(getdate()) as varchar(4)) + '-01-01' as date)

former_member203645
Active Participant
0 Kudos

Thanks , It worked

Answers (0)