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

Error in below scrip?

Calculate past 3 months total sales in stright table?

Datamodel:

Month sales

Dec.      500

Jan.       600

Feb.        800

Mar.      700

Apr.     400

I write below expression to get past three months total sales.

Sum({<Month_Num = {">=$(=AddMonths(Max(Month), -2)) <=$(=Max(Month))" >} Sales)



If month field available Dec and Jan like that. So how to convert to date.


My requirement calculate past 3 months sales.

Thanks

Chaitanya

7 Replies
mdmukramali
Specialist III
Specialist III

Hi,

Do you have Year Field in the Data Model?

Thanks,

Mukram

its_anandrjs
Champion III
Champion III

Do you have Numeric Month field it is shown in your expression let me know what fields you have.

its_anandrjs
Champion III
Champion III

If you have Numeric Month Field that try this way

Sum({< Month_Num= {">=$(=(Max(Month_Num)-2)) <=$(=Max(Month_Num))"} >} Sales)

gkcchowdary
Creator
Creator
Author

Hi anand I don't have numeric month field. If any way to convert my data into numeric date.

its_anandrjs
Champion III
Champion III

In your load script where you have Month filed put this line

Load

Num(Month(Month)) as NumMonth

From Source;

its_anandrjs
Champion III
Champion III

Ohh not this

Load

Num(Month(Month)) as NumMonth

Num(Month) as NumMonth

From Source;

Anil_Babu_Samineni

How you want to convert date if Dec is month?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful