Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Grouping by a calculated dimension by month

Good afternoon,

I have data that has information by customers per month. Within the data I have how many products the customer has and what are the balances for those products. What I need to do is group by month my customers and add all the balances for all the different products he/she may have and group then by tiers.

For example, I have the following data:

DateCustomerCustomer NumberAccountProductBalance
01/01/2014John DoeXXXX11234Tran $    1,000
01/01/2014John DoeXXXX14567Time $    3,000
01/01/2014Jane SmithXXXX28910Tran $    5,000
01/01/2014Jane SmithXXXX22345Time $    6,000
02/01/2014John DoeXXXX11234Tran $    1,000
02/01/2014John DoeXXXX14567Time $    2,000
02/01/2014Jane SmithXXXX28910Tran $    5,000
02/01/2014Jane SmithXXXX22345Time $          50
03/01/2014John DoeXXXX11234Tran $    5,000
03/01/2014John DoeXXXX14567Time $  11,000
03/01/2014Jane SmithXXXX28910Tran $  10,000
03/01/2014Jane SmithXXXX22345Time $  12,000

My Tiers are:

Tier 1<$1000
Tier 2$1000 to <$5000
Tier 3$5000 to <$10,000
Tier 4$10,000 +

My data should be grouped like this:

MonthCustomer NameCombined BalanceTier
JanuaryJohn Doe $                              4,000 Tier 2
Jane Doe $                           11,000 Tier 4
FebruaryJohn Doe $                              3,000 Tier 2
Jane Doe $                              5,050 Tier 3
MarchJohn Doe $                           16,000 Tier 4
Jane Doe $                           22,000 Tier 4

And in the front end I want to create a table with the Tiers as my dimension where the numbers would change according to the month I have selected. For example:

If January is selected, I want the table to show:

January
TiersNumber of Customers Balance
<$10000 $                                     -  
$1000 to <$50001 $                              4,000
$5000 to <$10,0000 $                                     -  
$10,000 +1 $                           11,000

If February:

February
<$10000 $                                     -  
$1000 to <$50001 $                              3,000
$5000 to <$10,0001 $                              5,050
$10,000 +0 $                                     -  

and If March is selected:

March
<$10000 $                                     -  
$1000 to <$50000 $                                     -  
$5000 to <$10,0000 $                                     -  
$10,000 +2 $                           38,000

Before I had this within my script, but when I created a master calendar, the month was no longer coming from the same resident table. Since I eliminated the month from the same table, the problem I am having now is that my addition of the balances is not filtering by month, so it is adding all my data together, therefore not giving me the correct breakdown per month.

1 Reply
MarcoWedel

Hi,

one solution could be:

QlikCommunity_Thread_143395_Pic1.JPG.jpg

QlikCommunity_Thread_143395_Pic2.JPG.jpg

QlikCommunity_Thread_143395_Pic3.JPG.jpg

QlikCommunity_Thread_143395_Pic4.JPG.jpg

QlikCommunity_Thread_143395_Pic5.JPG.jpg

tabCustBalance:

LOAD *,

    AutoNumberHash128([Customer Number],MonthName(Date)) as %CustMonthID

FROM [http://community.qlik.com/thread/143395] (html, codepage is 1252, embedded labels, table is @1);

tabCombBalance:

LOAD *,

    If([Combined Balance]<1000, 'Tier 1',

      If([Combined Balance]>=1000 and [Combined Balance]<5000, 'Tier 2',

      If([Combined Balance]>=5000 and [Combined Balance]<10000, 'Tier 3',

        If([Combined Balance]>10000, 'Tier 4')))) as Tier;

LOAD %CustMonthID,

    Money(Sum(Balance)) as [Combined Balance],

    MonthName(Date) as MonthName

Resident tabCustBalance

Group By %CustMonthID,MonthName(Date);

tabCalendar:

LOAD MonthName,

    Month(MonthName) as Month,

    Year(MonthName) as Year;

LOAD MonthName(AddMonths(MinMonth,IterNo()-1)) as MonthName

While AddMonths(MinMonth,IterNo()-1)<=MaxMonth;

LOAD MonthName(Min(Date)) as MinMonth,

    MonthName(Max(Date)) as MaxMonth

Resident tabCustBalance;

hope this helps

regards

Marco