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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anusha2011
Contributor
Contributor

Last 12 months for each month in Backend script

Hi Team,

I want to display monthly analysis in bar chart where every month shows last 12months of sales. Want to create last 12months field  for every month in backend .
example : Jan 2023,Feb 2023,March 2023,April 2023 these are my month dimension values in bar chart

Jan 2023 means it has to show Feb 2022 to Jan 2023 sales sum

Feb 2023 means it has to show March 2022 to Feb 2023 sales sum

March 2023 means it has to show April  2022 to March 2023 sales sum

April 2023 means it has to show May 2022 to April 2023 sales sum

like that I want to show in bar chart.

Please anyone help me to resolve this it is an urgent requirement in my project delivery.

Regards,

Anusha 

Labels (1)
4 Replies
BrunPierre
Partner - Master II
Partner - Master II

Hi, add this line within the Master Calendar to create a flag.

If(DateField <= Today() And DateField >= AddYears(Today(), -1), 1, 0) as Last12Months

With this as the sales expression.

=Sum({<Last12Months={1}>} Sales)

Anusha2011
Contributor
Contributor
Author

@BrunPierre thanks for your response but today function won't workout for my scenario.If we use today means it always takes current month but my scenario is it has to take individual month previous month to last 12 months .so, every month has different prev month.

saurav5246
Partner - Contributor III
Partner - Contributor III

Did u get the answer ?

marcus_sommer

You should implement an appropriate The As-Of Table - Qlik Community - 1466130 which linked each period with the previous 12 periods and is then used as dimension in your object.