Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
mlarruda
Creator II
Creator II

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.

Labels (1)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

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

View solution in original post

7 Replies
Vegar
MVP
MVP

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

mlarruda
Creator II
Creator II
Author

Worked! Thank you!

And excuse me too for my portuglish...

martinpohl
Partner - Master
Partner - Master

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

Vegar
MVP
MVP

Great @mlarruda !

Glad I could be of help.

To help others navigating in the community, please mark this question as answered. 

 

-Vegar

mlarruda
Creator II
Creator II
Author

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) 

 

Vegar
MVP
MVP

Like this:

SUM ({<COUNTRY = {'Brazil'}, YEAR = {2019}>} SALES) 
mlarruda
Creator II
Creator II
Author

Thank you very much!