Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
JeroenHoltrop
Contributor III
Contributor III

Conditionally sum or group a value

Hi,

I would like to be able to conditionally sum a dimension based on a grouping possibility. The situation is like this:

IDInvoiceIDGroupInvoiceIDValue
112345678050
2234567890150
3099999999450
4099999999600
5099999999230

We make a split between actual invoices and grouped invoices. What happens in our back-end system, is that we first calculate and store an invoice and then group them together. This results in a "0" value in the InvoiceID and a grouped invoiceID, which binds the invoices together. 

Now, with this, I would like to be able to show the values of a single invoice, so my report should result in 3 records: ID 1, 2 and a combination of 3-5 with a combined value of 1280. 

I cannot find a way to conditionally sum the value amounts based on the fact that the GroupInvoiceID is the same.

Can somebody help me with this?

Thanks a lot  

 

Labels (1)
1 Solution

Accepted Solutions
4 Replies
tresesco
MVP
MVP

I would prefer a script solution for this. However, a UI solution could be using calculated dimension like:

=If(GroupInvoiceID=0, ID, Aggr(NODISTINCT Min(ID)&'-'&Max(ID),GroupInvoiceID))

Capture.PNG

JeroenHoltrop
Contributor III
Contributor III
Author

Thanks for your reply. I see now that I left 1 important bit out, which basically is my need to still represent invoices 3-5, not grouped, but as single sub-invoices, but the total field should be summed. 

InvoiceIDinvoiceNumberValue
11234567850
223456789150
3999999991280
4999999991280
5999999991280

Reason for this, is that I need to show the details of all the subinvoices, with the total as full invoice amount.

Do you have an idea how to do that?

Thanks!

tresesco
MVP
MVP

Like this?

Capture.PNG

JeroenHoltrop
Contributor III
Contributor III
Author

Yes, of course, thanks a lot!