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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating a string from two field values in aggr function

Hi all,

I have following data:

CAL.CurrMonthCAL.CurrYearCAL.DateWeekStartCAL.DateWeekEndCAL.FiscalWMMonthCAL.FiscalWMYearCAL.WMMonthCAL.WMWeek
120121/21/20121/27/2012120112012/01201152
120121/14/20121/20/2012120112012/01201151
120121/7/20121/13/2012120112012/01201150
12201112/31/20111/6/2012120112012/01201149
12201112/24/201112/30/20111220112011/12201148
12201112/17/201112/23/20111220112011/12201147
12201112/10/201112/16/20111220112011/12201146
12201112/3/201112/9/20111220112011/12201145
11201111/26/201112/2/20111220112011/12201144
11201111/19/201111/25/20111120112011/11201143
11201111/12/201111/18/20111120112011/11201142
11201111/5/201111/11/20111120112011/11201141
10201110/29/201111/4/20111120112011/11201140
10201110/22/201110/28/20111020112011/10201139
10201110/15/201110/21/20111020112011/10201138
10201110/8/201110/14/20111020112011/10201137
10201110/1/201110/7/20111020112011/10201136
920119/24/20119/30/2011920112011/09201135
920119/17/20119/23/2011920112011/09201134
920119/10/20119/16/2011920112011/09201133
920119/3/20119/9/2011920112011/09201132
820118/27/20119/2/2011920112011/09201131
820118/20/20118/26/2011820112011/08201130
820118/13/20118/19/2011820112011/08201129
820118/6/20118/12/2011820112011/08201128
720117/30/20118/5/2011820112011/08201127
720117/23/20117/29/2011720112011/07201126
720117/16/20117/22/2011720112011/07201125
720117/9/20117/15/2011720112011/07201124
720117/2/20117/8/2011720112011/07201123
620116/25/20117/1/2011620112011/06201122
620116/18/20116/24/2011620112011/06201121
620116/11/20116/17/2011620112011/06201120
620116/4/20116/10/2011620112011/06201119
520115/28/20116/3/2011620112011/06201118
520115/21/20115/27/2011520112011/05201117
520115/14/20115/20/2011520112011/05201116
520115/7/20115/13/2011520112011/05201115
420114/30/20115/6/2011520112011/05201114
420114/23/20114/29/2011420112011/04201113
420114/16/20114/22/2011420112011/04201112
420114/9/20114/15/2011420112011/04201111
420114/2/20114/8/2011420112011/04201110
320113/26/20114/1/2011320112011/03201109
320113/19/20113/25/2011320112011/03201108
320113/12/20113/18/2011320112011/03201107
320113/5/20113/11/2011320112011/03201106
220112/26/20113/4/2011320112011/03201105
220112/19/20112/25/2011220112011/02201104
220112/12/20112/18/2011220112011/02201103
220112/5/20112/11/2011220112011/02201102
120111/29/20112/4/2011220112011/02201101
120111/22/20111/28/2011120102011/01201052
120111/15/20111/21/2011120102011/01201051
120111/8/20111/14/2011120102011/01201050
120111/1/20111/7/2011120102011/01201049
12201012/25/201012/31/20101220102010/12201048
12201012/18/201012/24/20101220102010/12201047
12201012/11/201012/17/20101220102010/12201046
12201012/4/201012/10/20101220102010/12201045
11201011/27/201012/3/20101220102010/12201044
11201011/20/201011/26/20101120102010/11201043
11201011/13/201011/19/20101120102010/11201042
11201011/6/201011/12/20101120102010/11201041
10201010/30/201011/5/20101120102010/11201040
10201010/23/201010/29/20101020102010/10201039
10201010/16/201010/22/20101020102010/10201038
10201010/9/201010/15/20101020102010/10201037
10201010/2/201010/8/20101020102010/10201036
920109/25/201010/1/2010920102010/09201035
920109/18/20109/24/2010920102010/09201034
920109/11/20109/17/2010920102010/09201033
920109/4/20109/10/2010920102010/09201032
820108/28/20109/3/2010920102010/09201031
820108/21/20108/27/2010820102010/08201030
820108/14/20108/20/2010820102010/08201029
820108/7/20108/13/2010820102010/08201028
720107/31/20108/6/2010820102010/08201027
720107/24/20107/30/2010720102010/07201026
720107/17/20107/23/2010720102010/07201025
720107/10/20107/16/2010720102010/07201024

I would like to get the last CAL.Week for each month. I used =AGGR(Date(MAX(CAL.Week)),CAL.CurrMonth). This gives me the last weeknumber for each month as expected when I only have one year to worry about. If my calendar contains data from 2009 to 2012 then my result only contains weeks for 2012. I know the limitation is based on the fact that the CAL.CurrMonth is from 1-12. Is there a way to create a sting by combining Cal.CurrMonth and Cal.CurrYear. This way I can get every last CAL.Week for each month for each year.

So basically I would like to somehow modify my AGGR function to something like =AGGR(Date(MAX(CAL.Week)),CAL.CurrMonth & CAL.CurrYear). Is this possible or do I have to load month/year as a field.

Thanks,

T

3 Replies
Anonymous
Not applicable
Author

Patel,

You can create the combined field, and you can create the new field month-Year, but it is not needed fro your purpose.  It is enough to aggregate by two fields:
=AGGR(Date(MAX(CAL.Week)),CAL.CurrMonth,CAL.CurrYear)

Not applicable
Author

A followup question is:

Thank you for the response.

How can I sum up the values for a field for all records containing CAL.Week using firstsortedvalue() for the above suggested aggregation?

I know we can use -CAL.week to get the last entry for each aggregation but I'm having some difficulties creating a set analsysi based on this aggregation.

I was hoping to find something along the lines of

=sum({$<CAL.week = {$(=firestsoretedvalue(CAL.week, -CAL.week)}>} Sales)

Any help would be appreciated.

Thanks,

T

Anonymous
Not applicable
Author

The quotation marks are missing in your expression.  Try this:

=sum({$<CAL.week = {"$(=firestsoretedvalue(CAL.week, -CAL.week)"}>} Sales)

Besides, it is simpler with max() function in your case:

=sum({$<CAL.week = {"$(=max(CAL.week"}>} Sales)