
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I set a condition in the SUM function?
Dear friends,
Suppose that I have a database with three variables (columns), with the first containing product names (strings), the second containing country names (strings) and the third containg sales (numbers). I want to build a table with the sums of sales per country for a given product.
So, I defined PRODUCT as Dimension and SUM (COUNTRY = 'Argentina' SALES), SUM (COUNTRY = 'Brazil' SALES) etc. as the Expressions, but these SUM functions are not working!
Anyone can help me please?
Many thanks in advance.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
SUM ({<COUNTRY = {'Argentina'}>} SALES)
and
SUM ({<COUNTRY = {'Brazil'}>} SALES)
The syntax between the outer { and } is called SET analysis. A good place to start learning about SET analysis is in the Qlik Help Set analysis and set expressions
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
SUM ({<COUNTRY = {'Argentina'}>} SALES)
and
SUM ({<COUNTRY = {'Brazil'}>} SALES)
The syntax between the outer { and } is called SET analysis. A good place to start learning about SET analysis is in the Qlik Help Set analysis and set expressions
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Worked! Thank you!
And excuse me too for my portuglish...


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
if you are creating a table (or another chart) with country as dimension and sum(SALES) as expression Qlik will generate a chart with calculated sales-values for each dimension automatically.
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great @mlarruda !
Glad I could be of help.
To help others navigating in the community, please mark this question as answered.
-Vegar
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will. Can I ask about what I need to do if I want to add another condition? Will the formula below work?
SUM ({<COUNTRY = {'Brazil'}>} {<YEAR = {2019}>} SALES)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much!
