Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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?
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.
What is the form of DTE? if it is like 04/04/2025 the the dollar sign does the math.
Yes, the form is MM/DD/YYYY.
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.
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
documentation about the parameter in Min function as always is available at https://help.qlik.com
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.