11 Replies Latest reply: Jul 14, 2015 5:30 AM by jagan mohan rao appala

# Logic Help

HI all,

i want one analysis Current year Vs Previous Year but in this i want suppose CY i having 4 month as Per Fiscal Year Apr,May,Jun,July 2015,

Now i want PY should contain Same Four month which as Current Year, Not Full year..

How i can do this??

• ###### Re: Logic Help

What you are describing, is called Current Year-To-Date vs. Prior Year-To-Date.

The function in QlikView and Qlik Sense that calculates that, is called InYearToDate(). It's common to pre-calculate YTD flags (simple 1/0 fields) for all Calendar dates, and to use the YTD flags in all chart expressions that require this logic.

I'm describing these techniques in a lot of detail in my new book QlikView Your Business, which is now featured on Qlik Market - check it out!

cheers,

Oleg Troyansky

• ###### Re: Logic Help

Hey Any one Here who can help me in this??

• ###### Re: Logic Help

Do u have date field in your app ...

• ###### Re: Logic Help

yes

Sum({<Fiscal Year = {'\$(=Max(Year))'} >}Sales)  for YTD

Sum({<Fiscal Year = {'\$(=Max([Year]-1))'} >}Sales)  for PYTD but it is giving me 12 month sales i want watever CY Month has been covered i.e. suppose for fiscal year 2015-2016 month Covered are Apr,May,Jun,July....

i want PYTD shud give Apr,May,Jun,July Sales while comparing.

thanks

Abhay

• ###### Re: Logic Help

Check the above expressions creating two variables.

Let me know if u have any issues.

• ###### Re: Logic Help

Create 2 Variables:

And Now Your expression will be :

PreYear:

=sum({<Year={'\$(=max(Year)-1)'},Date={'<=\$(vmax1)'},Month>}Value)

CurrYear:

=sum({<Year={'\$(=max(Year))'},Date={'<=\$(vmax)'},Month>}Value)

• ###### Re: Logic Help

Hi,

Try this expressions

Current Year:

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), 0, 4))<=\$(=Today())'}>} Sales)

Current Year:

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), -1, 4))<=\$(=YearEnd(Today(), -1, 4))'}>} Sales)

Replace Year, FiscalYear, Month, Quarter and DateFieldName with your actual field names.

Hope this helps you.

Regards,

Jagan.

• ###### Re: Logic Help

Check this Fiscal calendar generation script

Fiscal and Standard Calendar generation

Regards,

Jagan.

• ###### Re: Logic Help

Nice explanation. Thank you for answer.

• ###### Re: Logic Help

jagan mohan &lt;span class=&quot;icon-status-icon icon-mvp&quot; title=&quot;Mvp&quot;&gt;&lt;/span&gt; &lt;span class=&quot;icon-status-icon icon-partner&quot; title=&quot;Partner&quot;&gt;&lt;/span&gt; wrote:

Hi,

Try this expressions

Current Year:

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), 0, 4))<=\$(=Today())'}>} Sales)

Current Year:

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), -1, 4))<=\$(=YearEnd(Today(), -1, 4))'}>} Sales)

Replace Year, FiscalYear, Month, Quarter and DateFieldName with your actual field names.

Hope this helps you.

Regards,

Jagan.

Is this Previous Year?

Current Year:

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), -1, 4))<=\$(=YearEnd(Today(), -1, 4))'}>} Sales)

?

• ###### Re: Logic Help

Hi,

It is for Previous Year

Sum({<Year=, FiscalYear=, Month=, Quarter=, DateFieldName={'>=\$(=YearStart(Today(), -1, 4))<=\$(=YearEnd(Today(), -1, 4))'}>} Sales)

Regards,

Jagan.