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

How can we calculate , Previous 12 months Totals in Script level (Not in UI level)..

Hi All....

How can we calculate , Previous 12 months Totals in Script  level (Not in UI level)..

Thanks

Madhu

5 Replies
Not applicable

You may create another Fact table which will have Summary data and join this table to your main fact table.

svenkita
Creator II
Creator II

Let EndDate = MakeDate(2014,12,31);
Let StartDate = MakeDate(2014,1,31);

Item:
LOAD * INLINE [
ItemId, ItemName
1, Test Item 1
2, Test Item 2
]
;


Tmp:
LOAD * INLINE [
ItemId, Qty, Amount, SaleDate
1, 1, 1, 01/01/2014
1, 1, 1, 01/02/2014
1, 1, 1, 01/03/2014
1, 1, 1, 01/04/2014
1, 1, 1, 01/05/2014
1, 1, 1, 01/06/2014
1, 1, 1, 01/07/2014
1, 1, 1, 01/08/2014
1, 1, 1, 01/09/2014
1, 1, 1, 01/10/2014
1, 1, 1, 01/11/2014
1, 1, 1, 01/12/2014
2, 2, 2, 01/01/2014
2, 2, 2, 01/02/2014
2, 2, 2, 01/03/2014
2, 2, 2, 01/04/2014
2, 2, 2, 01/05/2014
2, 2, 2, 01/06/2014
2, 2, 2, 01/07/2014
2, 2, 2, 01/08/2014
2, 2, 2, 01/09/2014
2, 2, 2, 01/10/2014
2, 2, 2, 01/11/2014
2, 2, 2, 01/12/2014
]
;

TmpTotal:
Load ItemId, Sum(Amount) as TotalAmt
Resident Tmp
Where SaleDate >= '$(StartDate)' and SaleDate <= '$(EndDate)'
Group by ItemId;

Hope this Helps

madhubabum
Creator
Creator
Author

Hi Shivendoo Kumar,

Can u please give me an example...

Thanks for ur reply.

Thanks

Madhu

Kushal_Chawda

Please go through this link. This will really help you

https://community.qlik.com/docs/DOC-4252

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

LOAD

*,

If(DateFieldName > AddMonths(Today(), -12), 1) AS Last12MonthFlag

FROM DataSource;

Now in front end use

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

Hope this helps you.

Regards,

Jagan.