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: 
Not applicable

Set analysis with aggregation

Hi all,

I'm facing with a set analysis problem.

I want to compare for some given dimensions the same expression between the minimum and the maximum date in a pivot chart.

I try to explain better.

I have the following data model:

Field AField BDateValue
1AA01/01/20135
2BB02/01/201310
3CC03/01/201310
1AB04/01/201310
2AB05/01/201315
1AC06/01/201320

I want to obtain the following result:

Field Asum({<Date=(min(Date))>}Value)sum({<Date=(max(Date))>}Value)
1520
21015
31010

But the above set analysis does not work because checks the minimum and the max between all date set and the result is not correct.

I try also with FirstSortedValue, but it does not allow to aggregate value in a pivot chart.

Any help?

Thank you very much in advance.

Davide

1 Solution

Accepted Solutions
Not applicable
Author

I get the expected result with the following formulas:

=sum(aggr((FirstSortedValue(Value,Date)),"Field A","Field Z", "list_of_dimensions_in_pivot_table")).

Thanks to all.

Davide

View solution in original post

6 Replies
SunilChauhan
Champion II
Champion II

use below in your expressions

sum({<Date={$(=min(Date))}>}Value)

sum({<Date={$(=max(Date))}>}Value)

hope this helps

Sunil Chauhan
Not applicable
Author

Sorry, I post the wrong syntax.

I already used the expression you suggest but the result is not that I want.

The above set analysis search the min(date) between all date and not between the date relative to each Field A.

Not applicable
Author

FirstSortedValue works but if I have a pivot table with different dimensions on which I want to aggregate, without the sum aggregation, I'm not be able to get the same result.

For example:

Field ZField Asum({<Date=(min(Date))>}Value)sum({<Date=(max(Date))>}Value)
11520
121015
131010

Aggregating on Field Z with the SUM functions I should get:

Field Zsum({<Date=(min(Date))>}Value)sum({<Date=(max(Date))>}Value)
12545

With FirstSortedValue I don't get the above result.

Not applicable
Author

FirstSortedValue return to me the following if I aggregate on Field Z:

Field AFirstSortedValue(Value,Date)FirstSortedValue(Value,-Date)
1520

and not the sum of the values (25 and 45).

What QV version have you?

Not applicable
Author

I get the expected result with the following formulas:

=sum(aggr((FirstSortedValue(Value,Date)),"Field A","Field Z", "list_of_dimensions_in_pivot_table")).

Thanks to all.

Davide

karthikdaibala
Contributor
Contributor

Hi Davide,

i am trying to do the same, would you be able to explain this with some example.

Thanks

Karthik