Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculation YTD by month selected

Hi Guys,

I need your help..

How to write script, if I want to calculate YTD by month selected.

for example:

if I selected year 2014 and month may then accumulation (Jun13 - May14)

or if I selected year 2014 and month apr then accumulation (May13 - Apr 14)

or if I selected year 2013 and month jun then accumulation (Jul12 - Jun13)

Please help me..

thanks & regards..

25 Replies
Not applicable
Author

Hi Jagan,

I want random months selection, example if i selected May14, then Previous Year: Sum Jun12-May13

jagan
Luminary Alumni
Luminary Alumni

Hi,

If you want from Jan-13 - Dec-13, then use this

=sum({<Year=, Month=, Date={">=$(=YearStart(Max(Date),-23))<=$(=MonthEnd(Max(Date), -12))"}>}[Measure Field])


Hope this helps you.


If this not works come up with a sample file and expected output.


Regards,

Jagan.

richard_pearce6
Luminary Alumni
Luminary Alumni

Hi Valdi,

This 'AsOf' Calendar will give you the flags you need to complete this and other types of date analysis.

http://community.qlik.com/docs/DOC-6593

Regards

Richard

QlikCentral.Com

Not applicable
Author

Hi Jagan,

I was try your script, but the numbers accumulate all previous year 2013-2009.

and

I have a script :

sum({<DATE={">$(=addmonths(DATE,-24)) <=$(=addmonths(DATE,-12))"}, YEAR=, MONTH=>} AMOUNT

I think the script is true, because when I checked this script accumulate 12 months of Previous Year.

Btw, Thanks Sir Jagan...

Regards..

jagan
Luminary Alumni
Luminary Alumni

Hi Valdi,

Please close this thread by giving Correct and Helpful to the useful posts, this helps others in finding the answers for similar questions. 

Regards,

Jagan.

ankita1
Contributor
Contributor

Hi .

Please guide I am searching  one expression like if I select Month SEP 2023 then YTD field JAN 2023 TO SEP 2023 DATA  sales data will be there  using month and year field not date because summary table i am using please help me.