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: 
lessassy
Creator
Creator

Create a dynamic Target Line

Hello everyone,

I have a bar chart cycle drill (week and month) which highlights some KPI From 2015 to the Current Year.

KPI Indicator.PNG

Each year I have a monthly  and a weekly target for that KPI, which is for example:

2015: 200 monthly and 50 weekly

2016: 175 monthly and x weekly

2017: 175 monthly and so on

2018: 200 ....

SO i would like my target to change based on my dates week and month.

The thing is i tried to put in excel but it doesn't work because i have a master calendar.

DO you have any solution ? like a specific formula to apply ?

The goal is to let me or one of the key user just write down the kpi number in a variable.

So the calculation could be done automatically.

But if it's not possible how do I do for the values in the excel i posted.

Because Qlikview won't recognized a field with only MM (example: January --> KPI = 200).

Do you have a solution ?

Here are my sample files attached.

Thank you

32 Replies
avkeep01
Partner - Specialist
Partner - Specialist

It is a funny one. The calendar of 2018 only exists untill May, so that is just 6 months and thus the yearly target is divided by 151 days instead of 365.

You probably need to fix your calendar range:

Temp: 

Load 

               YEARSTART(min(Created)) as minDate, 

               YEAREND(max(Created)) as maxDate 

Resident MyTable1; 

lessassy
Creator
Creator
Author

Yes It's normal.

Because It's the current month.

Every week i have to display various kind of KPI in a meeting for my service.

So My datas are basically

Date: 05/05/18  Ticket Number: xxx5gg  KPI: 134 ISSUE: text / Assign TO: xxxx

So that's why i use a master calendar.

Thank you for the tip.

But unfortunately I have another issue

error yearend sentence.PNG

It appears that way because i made the change in the master calendar repalcing this : (

   min(Created) as minDate, 

               max(Created) as maxDate 

Resident MyTable1; ) by this

Temp: 

Load 

               YEARSTART(min(Created)) as minDate,

               YEAREND(max(Created)) as maxDate

Resident MyTable1; 

If you don't have the answer it's ok you helped me a lot.

Maybe there isn't a solution i don't know..

avkeep01
Partner - Specialist
Partner - Specialist

Hi Yann,

Sorry for the late reaction. YEAREND is 31-12-2018 23:59:59 which isn't a whole number. You can use ROUND( YEAREND(max(Created)),1) or DAYSTART( YEAREND(max(Created))), or FLOOR( YEAREND(max(Created))) to make it an integer instead of a decimal number.

Should be the last piece of the puzzle

lessassy
Creator
Creator
Author

It's working thank you !

But I have one last question (it really is my last one haha)

KPI (v).PNG

The script you gave me help to display the right target.

Although in my bar chart, it  displays the targets until the end of the year 2018. ANd currently we are in june so there is no need to display the following target value if there is no data to compare with.

Is there a way to display only the target when there is data value ?

Thanks a lot anyway

I made a huge step forward thanks to you

avkeep01
Partner - Specialist
Partner - Specialist

Hi Yann,

You can make a resident load on your target table where you use a where statement to limit the targets till current month.

FinalTarget:

NOCONCATENATE LOAD

Year,

Created,

KPI,

Target

RESIDENT Target

WHERE DAYSTART(MONTHEND(Created)) <= DAYSTART(MONTHEND(TODAY()));

lessassy
Creator
Creator
Author

Hi A.M. van Keep

Where do you put the script you gave me.

Because when i place in the emplacement below, it doesn't work.


// NoOfDays

temp01_Target:


NOCONCATENATE LOAD


Year,


COUNT(Created) AS [NoOfDays]


RESIDENT MasterCalendar


GROUP BY Year;



// target figures


LEFT JOIN (temp01_Target) LOAD


Year,


KPI,


Target*12 AS Target




INLINE [


Year, Target, KPI


2018, 120, LBTARGET

2018, 25, LETARGET

2018, 35, MTTRTARGET


2017, 300, LBTARGET

2017, 30, LETARGET

2017, 40, MTTRTARGET


2016, 600, LBTARGET

2016, 60, LETARGET

2016, 50, MTTRTARGET


2015, 300, LBTARGET

2015, 30, LETARGET

2015, 40, MTTRTARGET



];


Target:


NOCONCATENATE LOAD


Year,

Target/[NoOfDays] AS Target,

KPI




RESIDENT temp01_Target;



FinalTarget:

NOCONCATENATE LOAD

Year,

Created,

KPI,

Target

RESIDENT Target

WHERE DAYSTART(MONTHEND(Created)) <= DAYSTART(MONTHEND(TODAY()));


DROP TABLE temp01_Target;

LEFT JOIN (Target) LOAD


Year,


Created




RESIDENT MasterCalendar;

DROP FIELD Year FROM Target;

avkeep01
Partner - Specialist
Partner - Specialist

Hi Yann,

After the "DROP FIELD Year FROM Target;"

There you can past the following script:

FinalTarget:

NOCONCATENATE LOAD

Created,

KPI,

Target

RESIDENT Target

WHERE DAYSTART(MONTHEND(Created)) <= DAYSTART(MONTHEND(TODAY()));

DROP TABLE Target;

lessassy
Creator
Creator
Author

Thanks for the response.

I tried what you recommanded me.

dropfield year.PNG

But I get an error message unfortunately

Capture.PNG

When I load script, Qlikview can't located the created field

avkeep01
Partner - Specialist
Partner - Specialist

Hi Yann,

I wrote my script on the fly. So it wasn't good I guess. Try the following script instead.

FinalTarget:

NOCONCATENATE LOAD

Created,

KPI,

Target

RESIDENT Target

WHERE DAYSTART(MONTHEND(Created)) <= DAYSTART(MONTHEND(TODAY()));

DROP TABLE Target;

lessassy
Creator
Creator
Author

HI,

I still have an error message

Script Error - DYnamic Target.PNG

And Here is my script


// NoOfDays

temp01_Target:


NOCONCATENATE LOAD


Year,


COUNT(Created) AS [NoOfDays]


RESIDENT MasterCalendar


GROUP BY Year;



// target figures


LEFT JOIN (temp01_Target) LOAD


Year,


KPI,


Target*12 AS Target




INLINE [


Year, Target, KPI


2018, 120, LBTARGET

2018, 25, LETARGET

2018, 35, MTTRTARGET


2017, 300, LBTARGET

2017, 30, LETARGET

2017, 40, MTTRTARGET


2016, 600, LBTARGET

2016, 60, LETARGET

2016, 50, MTTRTARGET


2015, 300, LBTARGET

2015, 30, LETARGET

2015, 40, MTTRTARGET



];


Target:


NOCONCATENATE LOAD


Year,

Target/[NoOfDays] AS Target,

KPI




RESIDENT temp01_Target;


DROP TABLE temp01_Target;

LEFT JOIN (Target) LOAD


Year,


Created




RESIDENT MasterCalendar;


DROP FIELD Year FROM Target;



FinalTarget:

NOCONCATENATE LOAD

Created,

KPI,

Target

RESIDENT Target

WHERE DAYSTART(MONTHEND(Created)) <= DAYSTART(MONTHEND(TODAY()));

DROP TABLE Target;