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

AGGR/TOTAL - Lower Granularity Dimension

Hi,

I need to calculate a single value based on the following logic: If (Credit < Debit, Credit, Debit) aggregated on Customer Level.

CustomerAccountDebitCredit
1A11000
1A20200
2B1500450
3C1230550

I'm using the following expressions (same result) in order to achieve this:

Expression 1:

sum(Total<Customer> RangeMin(Debit,Credit))

Expression 2:

=sum(aggr(RangeMin(Debit, Credit),Customer))

The value I'm expecting is 780:

Customer 1: 100

Customer 2: 450

Customer 3: 230

However, the result I get is 680, because Customer 1 has two accounts (A1 and A2), and instead of summing the up, QV is calculating them separately.

How can I achieve QV to ignore the account dimension and calculate 780 in sum?

Many thanks,

Paul

1 Solution

Accepted Solutions
sunny_talwar

This?

=Sum({<Industry -={666}>}Aggr(RangeMin(Sum({<Industry -={666}>}Total <Customer> Debit), Sum({<Industry -={666}>}Total <Customer> Credit)), Customer))

View solution in original post

4 Replies
sunny_talwar

Try this:

Sum(Aggr(RangeMin(Sum(Total <Customer> Debit), Sum(Total <Customer> Credit)), Customer))

Anonymous
Not applicable
Author

Hi Sunny,

thanks for your post! It's working!

However, If I add a filter, I'm getting the value 0.

=Sum(

    aggr(

          sum({<

          Industry -={666}

          >}RangeMin(Sum(Total<Customer>Debit), Sum(Total<Customer>Credit))

      ),Customer)

)

sunny_talwar

This?

=Sum({<Industry -={666}>}Aggr(RangeMin(Sum({<Industry -={666}>}Total <Customer> Debit), Sum({<Industry -={666}>}Total <Customer> Credit)), Customer))

Anonymous
Not applicable
Author

Nice, thank you very much!