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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
PeroSero
Contributor II
Contributor II

Issues with Using Aggr() within Set Analysis

Hi All,

I have a measure that returns the date of the earliest gift given by a person (ID) with the unique identifier 'PAT':

=Min({<UNIQUE IDENTIFIER]={'PAT'}>} [DTE])

Now, I would like to create a measure that returns the date of the earliest gift made AFTER the one calculated above for the same person (ID). To do this, I am trying to Aggregate by ID within set analysis as follows:

=Min({<[DTE] = {">$(=Aggr(Min({<[UNIQUE IDENTIFIER]={'PAT'}>}[DTE]),[ID]))"}>} [DTE])

However, this results in null values for every ID.

I find this strange since when I test the Aggr() function outside of a Set Analysis, it returns the date I expect. But when I put it in the Set Analysis, it results in the Preview looking like:

=Min({<[DTE] = {">-}>} [DTE])

Does anyone know why this is? Is Aggr() not allowed within Set Analysis?

Thank you very much for any help!

Labels (2)
8 Replies
AJDoc31
Contributor III
Contributor III

I mimicked this in my dataset and it was not working until i made the Aggr function by the Unique identifier as well so in this case:

=Min({<[DTE] = {">$(=Aggr(Min({<[UNIQUE IDENTIFIER]={'PAT'}>}[DTE]),[UNIQUE IDENTIFIER]))"}>} [DTE])

 

I also tried your aggr out of the set analysis and it was not working. Maybe I am mistaken by why would you aggr by ID when you are looking at a person with a unique identifier?

PeroSero
Contributor II
Contributor II
Author

Hi @AJDoc31,

Thank you for trying that. Using [UNIQUE IDENTIFIER] in my Aggr didn't seem to work.

The reason I am trying to use Aggr() is because if I don't, then the Set Analysis is looking at the Minimum date for ALL records with a unique identifier of 'PAT'. However, I would like to look at the minimum date with unique identifier 'PAT' for each row (ID) individually and use that value in my set analysis instead.

ckarras22
Partner - Creator
Partner - Creator

What is the form of DTE? if it is like 04/04/2025 the the dollar sign does the math.

PeroSero
Contributor II
Contributor II
Author

Yes, the form is MM/DD/YYYY. 

ckarras22
Partner - Creator
Partner - Creator

Then as i mentioned, it is doing the math: $(=4/4/2025). I can't test it right now, to demo you where to put quotes etc, but in these cases, some  times i convert (or create another field in the model) to num.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

HI @PeroSero

in that case it does not make sense. Using $(=) already is looking at minimum for whole data set (and not for the row of the dimension in the table). I am not sure about your data model and how you have built your app but reading your requirement it seems you only need second minimum date:

Min({<UNIQUE IDENTIFIER]={'PAT'}>} [DTE],2)

Obviously parameter in Min() function can be used for that and you dont need any aggr() function.... however you will need ID as a dimension in the table where you want to display it.

To give you definite answer we would need to understand how you would like to use this measure. Putting it in the table is very different to putting it to KPI object as table has its dimensionality which needs to be considered when measure like this is created.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

documentation about the parameter in Min function as always is available at https://help.qlik.com

https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/Basic...

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
PeroSero
Contributor II
Contributor II
Author

Hi @Lech_Miszkiewicz,

Thank you for your help.

I would like the smallest date after the minimum gift with identifier 'PAT', regardless of the unique identifier of that gift.

I think that your solution, if I understand correctly, would give me the second minimum date for a gift with identifier 'PAT'.

I would like to use this measure in a table beside ID, which is a dimension.

I have tried these as well, which both resulted in a null value for all IDs:

=Min(Aggr(If([DTE] > Min({<[UNIQUE IDENTIFIER]={'PAT'}>} [DTE]),[DTE]),[ID]))
=Min({<[DTE]={"=([DTE] > Min({<[UNIQUE IDENTIFIER]={'PAT'}>} [DTE]))"}>} [DTE])

Thank you again for your help.