Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
felix18807
Contributor III
Contributor III

Aggr and {1} - no selection

Hi I'm trying to make an expression run ignoring all selections. I have created this expression (see below) to deduce time spent traveling but it is being affected by selections.

Can someone tell me where I'm going wrong?

 

SUM({1} AGGR({1} MRDuration,TravelLeg))

1 Solution

Accepted Solutions
Anonymous
Not applicable

This probably makes some sense, depending on what is to calcualte:

sum({1} aggr(SUM({1} MRDuration), TravelLeg))

View solution in original post

9 Replies
Anonymous
Not applicable

Not clear what aggr is doing here.  Try this

SUM({1} MRDuration)

hic
Former Employee
Former Employee

You should probably not use Aggr() at all.

Try Sum({1} MRDuration).

See also When should the Aggr() function NOT be used?

HIC

Anonymous
Not applicable

This probably makes some sense, depending on what is to calcualte:

sum({1} aggr(SUM({1} MRDuration), TravelLeg))

hic
Former Employee
Former Employee

Michael

Hypothetically, your 2nd formula may make sense, yes.

But only if one MRDuration can belong to several TravelLegs. If one record of MRDuration only can belong to one value of TravelLeg, then the Aggr() is redundant.

HIC

Anonymous
Not applicable

Henric,

Absolutely agree.  Just tying to keep it working even with aggr() - which is most likley redundant here.

Not applicable

can you attach ur qvw file?

felix18807
Contributor III
Contributor III
Author

I wish I could circumvent the aggr but what I have is a table of travel durations based on pairs of post codes and a table of stages of journey (per job) linked by a postcodepair key.

What I am looking to do on the dashboard is provide a total distance travelled but if I use Sum({1} MRDuration) I will get the sum of all the distances held in the distances table not the total distance travelled during all the jobs.

I hope I'm making sense...

hic
Former Employee
Former Employee

Since I do not have the data, I cannot help you.

But if a distance (MRDuration) can belong to/be used by several TravelLegs, then you should use the Aggr() function just like Michael Solomovich suggests:

sum({1} aggr(SUM({1} MRDuration), TravelLeg))

HIC

felix18807
Contributor III
Contributor III
Author

Thanks guys I believe that has resolved my issue.