Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Cors
Contributor II
Contributor II

Sum field only if Date field intersects with Total

I have a question regarding a problem I'm struggeling with.
The example below is a small subset of the real data, but the problem is the same.
The tabel loaded consists of 4 Columns: Name, Week, Day, Kg.

Question-Qlik Sense-table.png

I want to create a table with a layout like this:

Question- Qlik Sense-resultTable.png

For every Name I want to know the Sum of Kg that intersect on Day of the Total(Excluding himself).
outcome:
James : 81645
John : 25635
Michel: 94520

The days that James should sum are 19-4-2019,20-4-2019(because of John) and 15-4-2019(because of Michel)

And if I filter James and John, I want it to be:
James : 62622
John : 25635

I tried something like this:
Sum Kg if the day is also in the Total set

sum( Aggr(
   sum( if( count(Total distinct aggr(Name,Day)>1 ,Kg)))
,Name,Day)
)

But without succes.

1 Reply
Cors
Contributor II
Contributor II
Author

After somemore investigation

I think I found the answer.

But please correct me if I'm wrong, or if there's an easier way to do it!

sum(
{$<Day = {"=count(aggr(count(total distinct Name),Name,Day)) > 1"

} >}
Kg)

Basicly it states:

For the current selection give me the days that have more then 1 distinct Name's in the total selection.

More then 1 because the name of the current row is also in the Total.

Question- Qlik Sense-answer.png