Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Aggragating on a field with no corresponding data

I am trying to do the following - basically in my core data I have a field ("Added this Month") that identifies what month/year a client was added. In my chart I want to create a calculated dimension to check if the customer was new anytime in the current year and if so put a "Yes" in every line of the resulting chart.

   

DATA:
CustomerAdded this MonthProductMonthYearSales
AYes-201601-
ANoOak201603200
ANoPine201603300
ANoCedar201604400
ANoOak201605500
ANoPine201605600
RESULT I WANT:
CustomerAddMonthYearTotal Sales
AYes201603500
AYes201604400
AYes2016051100
1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like this:

Customer =Aggr(If(Sum({<Customer = p({<[Added this Month] = {Yes}, MonthYear = {"2016*"}>})>}1),'Add','-'),Customer) MonthYear Sum(Sales)
2000
AAdd201604400
AAdd201603500
AAdd2016051100

edit:

Using a straight  table chart with three dimensions (the second could also be converted to an expression)

1)

Customer

2)

=Aggr(If(Sum({<Customer = p({<[Added this Month] = {Yes}, MonthYear = {"$(=Year(today()))*"}>})>}1),'Add','-'),Customer)

3)

MonthYear

1 expression:

=Sum(Sales)

View solution in original post

3 Replies
swuehl
MVP
MVP

Maybe like this:

Customer =Aggr(If(Sum({<Customer = p({<[Added this Month] = {Yes}, MonthYear = {"2016*"}>})>}1),'Add','-'),Customer) MonthYear Sum(Sales)
2000
AAdd201604400
AAdd201603500
AAdd2016051100

edit:

Using a straight  table chart with three dimensions (the second could also be converted to an expression)

1)

Customer

2)

=Aggr(If(Sum({<Customer = p({<[Added this Month] = {Yes}, MonthYear = {"$(=Year(today()))*"}>})>}1),'Add','-'),Customer)

3)

MonthYear

1 expression:

=Sum(Sales)

swuehl
MVP
MVP

Another option would be to create the flag in the script, maybe like

Table:

LOAD Customer,

     [Added this Month],

     Product,

     MonthYear,

     Sales

FROM

[https://community.qlik.com/thread/225541]

(html, codepage is 1252, embedded labels, table is @1, filters(

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 8))

));

LEFT JOIN

LOAD Customer,

  MaxString(If(MonthYear LIKE Year(Today(1))&'*', [Added this Month])) as FlagThisYear

RESIDENT Table

GROUP BY Customer;

zagzebski
Creator
Creator
Author

Thanks!