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: 
Robert089
Contributor
Contributor

Aggregation over multiple fields/columns

Hi, I'm really new in Qlik so far but the most thinks are working with my basic understanding.

At the moment I have follwing issue:

I have several products with different timestamps. Each Product has a product number and a unique serial number and a time stamp.

Now I want to make following analysis.

1. Which serial number has a timestamp in the last 12 month

  • This one is easy, I added a calculated field in the table of data manager

2. Which serial number has more or equal than 2 timestamps in the last 12 month

  • This aggregation works for me as I did for example a table in the analysis section and did the calculation with sum(calculated field)

3. Now I want to find out which product number has a serial number which has >=2 time stamps in the last 12 month

  • This aggregation doesn't work at the momemt as I have the issue, that I not know how I can aggregate the "sum(calculated field)" which is shown as a result in a table (as described in 2.) 
  • My first intention was to make an aggregation of the table I created in step 2. But that not worked yet. (Is it possible in general)?
  • My second try was to build a new tabel in data manager with aggregated serail numbers in the last 12 month. But I couldn't find out how or if this is working

 

Do you have an idea how I can solve my issue how to aggregate over two fields?

 

 

3 Replies
GaryGiles
Specialist
Specialist

I believe that you can answer all three of these questions using set analysis in a table chart, instead of creating new fields.  For your dimension in a table chart, use the following expressions.  Results below.


Question 1: =aggr(Only({$<Timestamp={">$(=Addmonths(Today(),-12))"}>}[Serial Number]), [Serial Number])

Question 2: 

=aggr(Only({$<[Serial Number]={"=Count({$<Timestamp={"">$(=Addmonths(Today(),-12))""}>} Timestamp)=2"}>}[Serial Number]), [Serial Number])

Question 3:

=aggr(Only({$<[Serial Number]={"=Count({$<Timestamp={"">$(=Addmonths(Today(),-12))""}>} Timestamp)>2"}>}[Product Number]), [Product Number])
 

GaryGiles_1-1619092590677.png

 

Robert089
Contributor
Contributor
Author

Thanks, that helped me a lot!

Robert089
Contributor
Contributor
Author

I tried to finally get a clue to solve my issue with the aggr described above. As a final result I'm going to expect a table in QLIK like following: 

Product numer | Number of Serial Number with more than 2 timestamps in the last 12 month

1234567 | 1

45378923 | 0

7437372 | 0

3452354 | 0

4353454 | 0

How should the formula look like for "Number of Serialnumbers with more than 2 timestamps in de last 12 month"