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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last 3 months in Set Analysis

Good day

I have the following calculations on my set analysis:

sum({<L_WRITTEN_OFF_L3M_IND={'Y'}, L_CREDIT_DEBIT_IND={'DB'},L_NCA_PRODUCT_CODE={'UNL'}, L_NCA_IND={'J','Y','X'}>}[L WRITTEN OFF AMOUNT])

Now I want to use this set to calculate for the last three months.

Your assistance will be highly appreciated.

Kind regards,

Mbini

1 Solution

Accepted Solutions
Kushal_Chawda

Make sure that Your Date field is not the string, to check this create the Text object and put the expression "=max(Date)", if you get '-' means it is not in Date format, if you get the Values , it means it is in Date format.

If it is not in Date format, use Date# function to make it in Date format, then use below expression

sum({<

  L_WRITTEN_OFF_L3M_IND={'Y'},

  L_CREDIT_DEBIT_IND={'DB'},

  L_NCA_PRODUCT_CODE={'UNL'},

  L_NCA_IND={'J','Y','X'},

  Date ={">=$(=addmonths(max(Date),-3)) <=$(=max(Date))"}>} [L WRITTEN OFF AMOUNT])

View solution in original post

10 Replies
mightyqlikers
Creator III
Creator III

create a variable like vMonStart = monthstart(addmonths(datefield,-3))

vMonEnd = dateField

sum({<L_WRITTEN_OFF_L3M_IND={'Y'}, L_CREDIT_DEBIT_IND={'DB'},L_NCA_PRODUCT_CODE={'UNL'}, L_NCA_IND={'J','Y','X'},DateFeild ={'>=$(vMonStart ) <=$(vMonEnd )'}>}[L WRITTEN OFF AMOUNT])


Regards

$@M.

Kushal_Chawda

What is this Flag L_WRITTEN_OFF_L3M_IND?

Not applicable
Author

yes its a flag

Kushal_Chawda

So is this Last 3 months Flag?

Not applicable
Author

its a flag that checks if its been written off in the last three months

Not applicable
Author

my datefiled is 'Date'

jonathandienst
Partner - Champion III
Partner - Champion III

Define the variables: ( I always do this in the load, but you can use the variable overview as well):

Set vPeriodStart = '=AddMonths(Max(Date))';

Set vPeriodStart = '=AddMonths(Max(Date), -3)';

Set vPeriodEnd = '=Date(Max(Date))';

Then use the expression:

sum({<

  L_WRITTEN_OFF_L3M_IND={'Y'},

  L_CREDIT_DEBIT_IND={'DB'},

  L_NCA_PRODUCT_CODE={'UNL'},

  L_NCA_IND={'J','Y','X'},

  Date ={">=$(vPeriodStart) <=$(vPeriodEnd)'}>} [L WRITTEN OFF AMOUNT]

)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Try this

sum({<L_WRITTEN_OFF_L3M_IND={'Y'}, L_CREDIT_DEBIT_IND={'DB'},L_NCA_PRODUCT_CODE={'UNL'},L_NCA_IND={'J','Y','X'},DATEFIELD={">=$(=MonthStart(max(DATEFIELD),-3))<=$(=max(DATEFIELD))"}>}[L WRITTEN OFF AMOUNT])

Not applicable
Author

I have tried this, I get a negative value