Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with Set analysis

Hi Friends,

I have a requirement to show minimum month data by customer. I tried set analysis to do this but its not working as expected. Could anyone please help me on this issue.

I greatly appreciate your help in advance

My original data set is

Cust IDMonthYearQuantity
112Feb-1210
111Mar-1210
114Apr-1210
117Mar-1210
111Apr-1220
112Apr-1220
121Jan-1210

Correct Output

Cust IDMinimum MonthMonth Quantity
112Feb-1210
111Mar-1210
114Apr-1210
117Mar-1210
121Jan-1210

Set analysis i used to restrict the min month in expression is

 

sum

({<MonthYear={'$(=MinString(MonthYear))'}>}Quantity

)

output i am getting is

CustIDMin MonthMin Month Quantity
Apr-1250
111Apr-1220
112Apr-1220
114Apr-1210
117Mar-120
121Jan-120

I have attached my qvw file as well.

12 Replies
swuehl
MVP
MVP

Hard to say what you want to do here, you'll need at least to post your variable definitions, too. At best, post a small sample file that demonstrate your issue.

One thing I already noticed, you are using an aggregation function inside another aggregation function (sum() inside FirstSortedValue() ). This is not allowed without using advanced aggregation (aggr() function).

Not sure if you need to use sum() at all, you could potentially just use a set expression with the FirstSortedValue() function.

Not applicable
Author

Thanks you, i made it work using firstsortedvalue function. But the function is returning null when there are multiple records for specific month. How can i avoid this null and group to monthly level in frontend?

Please look at the attached example. I have added extra records to customer 112 and spitted feb-12 quantity into multiple dates. In front end its showing null for customer 112. Is there any way to show the proper total(10) for feb-12 without grouping data at monthly level?

swuehl
MVP
MVP

Try something like

=FirstSortedValue(aggr(sum(Quantity),CustID,Monthstart),aggr(Monthstart,CustID,Monthstart))