Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Contribution % - MAT, YTD, MTD for PreviousYear

Hye folks,

I am trying to figure out how to script the contribution % for previous years.

Any ideas?

Best Regards,

Ram

7 Replies
Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

Hi Try This... Hope This will help you

YTD & PrevYTD

=sum({<CommonDateField={'>=$(VPrevYear)<=$(vMaxDate)'}>}Sales)

VPrevYear=Date(Yearstart(vMaxDate,-1),'DD/MM/YYYY')

For MTD Prv MTD

=sum({<CommonDateField={'>=$(VPrevMonth)<=$(vMaxDate)'}>}Sales)

Variables:

VPrevMonth=Date(MonthStart(vMaxDate,-1),'DD/MM/YYYY')

vMaxDate=Date(max(CommonDateField),'DD/MM/YYYY')

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

Hi Nirmal,

Sorry - your explanation is kinda vague. A more descriptive clarification would be appreciated.

My main concern is how do I create a <$Year={(MAX)Year - 1> variable?

This would definitely help me out, put me on the right path.

Much appreciated.

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

Try Like this

=max(Year(date(CommonDate,'DD/MM/YYYY'))-1)

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

try this  {"=$(=Max(Year)-1)"}

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

if you use many YTD and comparison vs previous year, you can

1) use complex set analysis  (take care, you must have only ONE year in your graph)

2) modify your model  (you can have several months & years in your graph)

see a doc I have written on that subject : http://community.qlik.com/docs/DOC-4821

Fabrice

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

Hi Thomas,

Doesn't work. Syntax error.

Not applicable

Re: Contribution % - MAT, YTD, MTD for PreviousYear

try this:

=sum({<Year={$(=only(Year)-1)}>} measure )

Community Browser