Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem Using Set Analysis

Dear All,

Sum({$<MonthNameSort={'$(vLast6YearMonth)'},[Company Type]={'OWN'},[Sales Type]={'G ORDER'}>} Qty)

i am using the above set analysis expression to calculate a value.But it is not working

My monthNameSort is the field which is made by using monthname function on the Date and give the values e.g Apr 2010 , Mar 2010 and vLast6YearMonth is the variable which is addmonths(MAX(MonthNameSort),-6) so i want want to select a value for the previous 6th month.

and i use Sum({$<MonthNameSort={">=$(vLast6YearMonth)"},[Company Type]={'OWN'},[Sales Type]={'G ORDER'}>} (Qty)/12) then it waorks fine and gives the sum for last six months

but the above first expression is not working where i want to calculate the value for only the last 6th month.

Can any one suggest what is wrong in it.

Thanks in advance.

Rahul







1 Solution

Accepted Solutions
Not applicable
Author

Hi

Have you verified that your first formula provides correct results?

Is your MonthNameSort a date value?

Encountered the problem that in SET expressions the date needs to be a string according to the specified date settings. Can your try to replace vLast6YearMonth with a string value e.g. 'Apr 2010' and verify that you get correct results?

Juerg

View solution in original post

4 Replies
Not applicable
Author

What is the format of the variable being spliced into the Set Analysis. If its not coming out as something QV understands as a numeric value then the >= will not work against it. Try outputing your expression to a Text Object to see how the code looks with the variable value in the expression.

Also you may want to post a small sample app, or describe "not working." Are you getting null, the wrong value, or an error message?

Not applicable
Author

When i am using >= it is working but when i just want to calculate the value for only the last 6th month for which i have declared the variable " vLast6YearMonth" then it is not working . When using my expression in textbox i.e

Sum({$<MonthNameSort={'$(vLast6YearMonth)'},[Company Type]={'OWN'},[Sales Type]={'G ORDER'}>} Qty)

it is giving zero as output and format of my variable is DD/MM/YYYY eg 01/03/2010





Not applicable
Author

Hi

Have you verified that your first formula provides correct results?

Is your MonthNameSort a date value?

Encountered the problem that in SET expressions the date needs to be a string according to the specified date settings. Can your try to replace vLast6YearMonth with a string value e.g. 'Apr 2010' and verify that you get correct results?

Juerg

Not applicable
Author

ya i tried with Apr 2010 in place of variable but it was not giving the result but in my monthnamesort field i have values like Apr 2010, Mar 2010