Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
psk180590
Creator III
Creator III

YTD in qlikview

Hello All,

I'm looking to generate a chart for YTD current year vs YTD last year. I have many values to calculate(Sales, Quantity, Per Country, Per State, Per Region etc.,). Each of this will be having a separate chart.

Can you please help me with a single variable to define YTD current year and another one to define YTD last year.

I would like to use this in the chart expressions.

Thanks,

Best Regards

Sai.

14 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

YTD Flag:  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,

LYTD Flag:  inyeartodate(Date, $(vDateToday), -1,4)* -1  AS LastYTDFlag

Try this in script make flag.In front end write expression as :

YTD       =sum({<YTD={'1'}>} Sales)

LYTD  =sum({<LYTD={'1'}>} Sales)

Hope this will helps u..!!

Regards,

Mohammad

Anonymous
Not applicable

It tried it with your example in a textbox, it worked...

Kushal_Chawda

try this

YTD:

=sum({<Date={">=$(=Yearstart(today()))<=$(today())"} >} Sales)

Y-1TD-1:

sum({<Date={">=$(=Yearstart(AddYears(today(),-1)))<=$(=AddYears(today(),-1))"} >} Sales)

psk180590
Creator III
Creator III
Author

Hello All,

Firstly thanks for all your suggestions.

This is turning out to be bit more complicated then i thought it would. So, here is what i'm looking to do.

Get YTD current year vales for each month.

    • 1st-31st Jan is YTD Jan
    • 1st Jan to 28th Feb is YTD Feb
    • 1st Jan to 31st Mar is YTD Mar
    • 1st Jan to 30th Apr is YTD Apr
    • And so on for the preceding months.

I was able to achieve the YTD for my data upto May 31st(i.e., 1st Jan to 31st May) but it works only without the Month dimension in my chart.

Now, what i would like to have is to generate a value for each point mentioned above and have them with a month dimension.

NOTE: I believe that having date formulas would be better as i have many expressions(Sales and  Quantity of three different types). I mean having a Date variable that would get me the Period from 1st Jan to 31st Jan and the next one to get Period from 1st Jan to 28th Feb and so on.

Anonymous
Not applicable

when you have multiple years why do use use month instead of yearmonth as dimension?

basically it should work with something like  rangesum(above(sum(Sales),0,RowNo())

if YearMonth is the only dimension and YearMonth is sorted ascending.