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

Aggr with condition

Hello,

I'm trying to add a column (total dif) showing the value aggr of difference between "Objective" and "Actual" values, if that is greater than 0.

Ex.:

ClientObjectiveActualDifferenceTotal Dif.
A01106 106106
A0197622300106
A014207420106
1 Solution

Accepted Solutions
Steven_Haught
Creator III
Creator III

@Cantelli 

Ok, I do think your math in that table is slightly off but I think I have figured this out.  @sunny_talwar did this in another similar situation, so don't want to take full credit! 

=RangeSum(Above(TOTAL Sum(Difference), 0, Aggr(Dim, Group, SubGroup))) 

This should work for you. This is doing two things in the load. 

1. Since I was doing inline load I created a unique num for each record. This could be done using RowNo() in the load if you are using regular load. *see attached solution for Sunny's breakdown. 

2. I also went ahead and created the Difference field in load so I could reference in the formula. 

Resulting table will look like this:

 
 
 
 
DimClientGroupSubGroupObjectiveActualDifferenceRange Sum
1A01115W262333
2A01217P1060106109
3A01217S9762230-109
4A01217M420742-109
5A02237M21040170279
6A02237S22660166445
7A02237P662046491

 

Previous Solution for Reference:

https://community.qlik.com/t5/QlikView-Creating-Analytics/RangeSum-with-Aggr/td-p/930324

Let me know if that works! 

Thanks,

Steven 

View solution in original post

4 Replies
Steven_Haught
Creator III
Creator III

Try this it worked for me:

=(sum(total if(Objective-Actual>0,Objective-Actual)))

Cantelli
Contributor II
Contributor II
Author

Steven, thank you for the answer.

It isn't worked, but it's my fault. Let me show you more information.

That is my complete base. The column "Result" is your solution. "Total Dif" is my target. 

ClientGroupSub GroupObjectiveActualDifferenceTotal Dif.Result
A01115W26233391
A01217P106010610691
A01217S9762.2300 91
A01217M4207420 91
A02237M2104017038291
A02237S2266016638291
A02237P66204638291
Steven_Haught
Creator III
Creator III

@Cantelli 

Ok, I do think your math in that table is slightly off but I think I have figured this out.  @sunny_talwar did this in another similar situation, so don't want to take full credit! 

=RangeSum(Above(TOTAL Sum(Difference), 0, Aggr(Dim, Group, SubGroup))) 

This should work for you. This is doing two things in the load. 

1. Since I was doing inline load I created a unique num for each record. This could be done using RowNo() in the load if you are using regular load. *see attached solution for Sunny's breakdown. 

2. I also went ahead and created the Difference field in load so I could reference in the formula. 

Resulting table will look like this:

 
 
 
 
DimClientGroupSubGroupObjectiveActualDifferenceRange Sum
1A01115W262333
2A01217P1060106109
3A01217S9762230-109
4A01217M420742-109
5A02237M21040170279
6A02237S22660166445
7A02237P662046491

 

Previous Solution for Reference:

https://community.qlik.com/t5/QlikView-Creating-Analytics/RangeSum-with-Aggr/td-p/930324

Let me know if that works! 

Thanks,

Steven 

Cantelli
Contributor II
Contributor II
Author

It's worked. Thank you @Steven_Haught