Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
rahulsingh12
New Contributor III

YTD In Qlikview

Hi,

I have two fields year and month as text.

I want to calculate YTD for current selected Month by the user.

Thus if the user selects jan it should give sum of sales for Jan only if they select Feb they should get for Jan and feb and hence forth.

I wrote the following code:

sum({<MonthYear={">=$(=vMinYearMonth)<=$(=vMaxYearMonth)"}>}[Volume])

I created a field YearMonth by converting Month into numbers and concatenating with Year.

Thus vminyearmonth is min YearMonth for any selected Month,similary vMaxYearMonth is max of YearMonth  for any selected yearmonth(In this case the selected month).

But the sum I get is only for the selected month not YTD.

what is it that I am doing wrong.


Regards.

7 Replies
thiago_pinho
New Contributor III

Re: YTD In Qlikview

Hello Rahul,

Try This,

     Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)

thiago_pinho
New Contributor III

Re: YTD In Qlikview

You should take a look in this post:

YTQ, QTD, MTD and WTD

prat1507
Valued Contributor

Re: YTD In Qlikview

Hi

Since you want YTD values, for ex. if you select Feb, you must have the sum for Jan,Feb. Since this is the intent, your vMinYearMonth should not depend on the selected month and must be fixed.

Since you haven't fixed it, when you select Feb, it selects both vMinYearMonth and vMaxYearMonth as Feb for the selected year and similarly for any other selected month.


Just add Month= in your vMinYearMonth  set analysis expression.


I hope this would work.


Regards
Pratyush

rahulsingh12
New Contributor III

Re: YTD In Qlikview

Hi Pratyush,

I have tried that.

But it doesnt seem to work.

Regards,

Rahul

Re: YTD In Qlikview

We need variable definition too, Because vMinYearMonth need to be calculated like YearStart(Min(Year))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
rahulsingh12
New Contributor III

Re: YTD In Qlikview

It is working.

can you tell me how will I last year YTD for same selected month and year?

Regards,

Rahul

Re: YTD In Qlikview

Like this?

YearStart(AddYears(Today(),-1))

Month(AddYears(Today(),-1))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)