# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
cancel
Showing results for
Did you mean:
Specialist

## Calculate QTD and YTD in Script

Hi,

I have a date field which has data like Jan-15,Feb-15,Mar-15,........ Dec-15,Jan-16,Feb-16,.....Dec-16 and so on

I have calculated Quarter using below expression

'Q' & Ceil(Month(Date)/3) & '-' & Right(Year(Date),2)) as Date

How to calculate QTD and YTD in script same way?

6 Replies
MVP

You can use the QV date functions InQuarterToDate() and InYearToDate() to flag your Date values. Then group by these flags to aggregate the facts, or use the flag in the frontend to filter the records.

Not applicable

Hi Uday

Is your Calendar actually at date or month level?

Partner

if(if(Month(date(Floor(Date)))<=3,(Year(date(Floor(Date)))-1)&'-'&(Year(date(Floor(Date)))),(Year(date(Floor(Date))))&'-'&(Year(date(Floor(Date)))+1))=if(Month(((today())))<=3,(Year(((today())))-1)&'-'&(Year(((today())))),(Year(((today()))))&'-'&(Year(((today())))+1)),1,0) as YTD_Flag,

Try this for YTD in Script

Partner

'Q' & (ceil(WildMatch(month(Date),'Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb','Mar')/3)) as QTD

Try this for QTD in Script

Hope this will helps u...!!!

Regards,

Champion
Specialist
Author

Hi all,

The date is at month level.

I have to show month, quarter, QTD and YTD all in same field like this

I have calculated Quarter using months, now i want QTD and YTD for the current year.

So how to get it and append that QTD and YTD to date field as shown below in table

This is a pivot table so i have dragged the date field horizontally in the table.

Dim1YTDQTDQ4-15Dec-15Nov-15Oct-15Q3-15Sep-15Aug-15Jul-15Q2-15Jun-15May-15Apr-15Q1-15
A1001104565656565656
B555555555555555
C555555555555555