Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Hauglaen
Contributor II
Contributor II

Sum Distinct and/or Aggr

Hello,

I have a dataset below. How do I sum only the transactions where the net price is between 0-50% of the Gross price?

DateIDTransaction numberNet priceGoss priceSales channelPrice groupCopies sold
22.03.201914240663769381,6501014
28.01.201914235938269381,6501011
08.01.2019142359368235381,6501011
03.01.2019142359367255381,6501011
22.03.201915233573369381,6501014
28.01.2019152321550235381,6501011
08.01.2019152307368235381,6501011
03.01.2019152293185255381,6501011

 

Desired sum for copies sold are 5 (ID 14) and 4 (ID 15).

I currently have:

 if
 (
 sum({$< Price group ={'01'},Sales channel={'01'} >} Net price)/sum({$< Price group ={'01'},Sales channel={'01'} >} Goss price)<0.50
 and
 sum({$< Price group ={'01'},Sales channel={'01'} >} Net price)/sum({$< Price group ={'01'},Sales channel={'01'} >} Goss price)>0,
 sum({$< Price group ={'01'},Sales channel={'01'} >} Copies sold)
 )

Do I include Aggr and/or Distinct?

Much appreciated!

1 Solution

Accepted Solutions
kaanerisen
Creator III
Creator III

Hi Hauglaen,

You can achieve that by using simple set analysis if I get what you desire correctly.

sum({<[Transaction number]={"=[Net price]/[Goss price]<0.5"}>}[Copies sold])

If you have extra criterias you should add that to set analysis of expression.

Untitled.png

Hope it helps..

View solution in original post

6 Replies
marcus_sommer
MVP
MVP

For me it looked that you don't need the whole summing-stuff and that the following should be enough:

sum({$< [Price group] = {'01'}, [Sales channel] = {'01'},
                  [Net price] = {"=[Net price]<[Gross price]*0.5"} >} Copies sold)

- Marcus

Hauglaen
Contributor II
Contributor II
Author

Thank you!

I am displaying the the data in a table with only ID and Copies sold.

Your solution results in an empty table, but if I filter out an ID, the table shows the correct number of copies sold for that ID.

Do you have any suggestions?

 

marcus_sommer
MVP
MVP

In this case you need to enforce the check on the appropriate level, maybe with something like this:

sum(aggr(
sum({$< [Price group] = {'01'}, [Sales channel] = {'01'},
                  [Net price] = {"=[Net price]<[Gross price]*0.5"} >} Copies sold),
[Transaction number]))

- Marcus

Hauglaen
Contributor II
Contributor II
Author

I get the same result.

kaanerisen
Creator III
Creator III

Hi Hauglaen,

You can achieve that by using simple set analysis if I get what you desire correctly.

sum({<[Transaction number]={"=[Net price]/[Goss price]<0.5"}>}[Copies sold])

If you have extra criterias you should add that to set analysis of expression.

Untitled.png

Hope it helps..

marcus_sommer
MVP
MVP

Normally it should work. If the [Transaction number] isn't unique within the context of this calculation you might need to add further dimensions maybe the ID.

- Marcus