Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
jjking58
Contributor III
Contributor III

Previous Year on Straight table

Can someone explain how to get the previous ytd based on a year/month selection.

When I click on Dec.2016. I'm getting the entire month of Dec 2015 instead of YTD

The code is below for current and previousCap1.PNG

Thanks I greatly appreciate it

Jim

Labels (1)
9 Replies
vishsaggi
Champion III
Champion III

Are you using a calendar script in your dashboard. ? Can you share a sample app if possible ?

jjking58
Contributor III
Contributor III
Author

No i'm not using a calendar script. i took a field within a data base called IHIDAT and separated it into month/year/day

using the qlikview functions(month,year,day).

joseduque
Partner - Contributor III
Partner - Contributor III

Hi,

If you dont want the other selections make changes to your data use 1 in the set analysis. Ex:

sum({1<IDPAGR={'MECH'},Year={"$(=max(Year)-1)")}>}

Also you forget to use "" in the YTD sentence "$(=max(Year)-1)"

vishsaggi
Champion III
Champion III

What is your expected output for YTD here? Can you share a sample app with some scrambled data?

vishsaggi
Champion III
Champion III

If possible try the script attached with this and let me know how it works?

varshavig12
Specialist
Specialist

For YTD, you have to give a date range.

neha_shirsath
Specialist
Specialist

Hi Jim,

Please see the below link for CYTD and LYTD.

YTQ, QTD, MTD and WTD

Thanks & Regards,

Neha

Michiel_QV_Fan
Specialist
Specialist

Jim, find the qlikview components (GitHub - RobWunderlich/Qlikview-Components: A library for common Qlikview Scripting tasks) on the internet and use the calendar generation script from there. Besides a default calendar it can also generate the set analysis statements you need for selecting specific time frames.

jjking58
Contributor III
Contributor III
Author

Neha,

I tried using the formulas from this post. which are listed below. The CYTD works,but the PYTD is not giving me totals and show the dates from CYTD.

IHIDAT is in format YYYYMMDD and the Dateformat in the script is also set to YYYYMMDD. Does this make a difference ?

CYTD

Sum({<IDPAGR = {'EQUP'},OrderType-={'TI'}, Year=, Month=, IHIDAT={">=$(=Num(YearStart(Max(IHIDAT))))<=$(=Max(IHIDAT))"},NOAGRP-={'INTR'}>} Amount)

PYTD

Sum({<IDPAGR = {'EQUP'},OrderType-={'TI'}, Year=, Month=, IHIDAT={">=$(=Num(YearStart(Max(IHIDAT),-1)))<=$(=AddYear(Max(IHIDAT),-1)"},NOAGRP-={'INTR'}>} Amount)

Please advise,

Jim