Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
sheker_amrutham
Contributor II
Contributor II

Help in Set Analysis - Calculation conditions

Hi,

My requirement is to display Sum of SalesAmount for ProdA and ProdB , For ProdA it should calculate Sales Amount for Year is 2016 and Jan, Feb of 2017 and For ProdB it should display Sales Amount of Year 2018. I need to write single expression to display this measure.
Can some one help on this scenario. 

SnoProductIdSaleDateSaleAmount
1ProdA01-01-2016250
2ProdB01-05-2016600
3ProdB01-09-2016600
4ProdA01-10-2016260
5ProdA02-10-2016650
6ProdA03-10-2016400
7ProdA01-01-2017600
8ProdB01-02-2017600
9ProdA01-02-2017950
10ProdB09-09-2017500
11ProdA01-01-2018600
12ProdB02-01-2018600
13ProdB03-01-2018260
14ProdA04-01-2018260
15ProdB05-01-2018650
16ProdB06-01-2018500
17ProdB07-01-2018600
18ProdB08-01-2018250
19ProdA09-01-2018600
20ProdA10-01-2018300
Labels (1)
1 Solution

Accepted Solutions
kushalthakral
Creator III
Creator III

Hi Sheker

 

You can use union (+) in set analysis like below

=Sum({<ProductId = {'ProdA'}, SaleDate = {">=01/01/2016<01/03/2017"}> + <ProductId = {'ProdB'},SaleDate = {">=01/01/2018<=31/12/2018"}>}SaleAmount)

and output will be like below

 

Capture.PNG

I hope this answers your question

 

Thanks

Kushal

View solution in original post

2 Replies
bramkn
Partner - Specialist
Partner - Specialist

sum({<ProductId={'ProdA'},SaleDate={">=01-01-2016 <01-03-2017"}>}SalesAmount)+ sum({<ProductId={'ProdB'},SaleDate={">=01-01-2018 <01-01-2019"}>}SalesAmount)
keep in mind it is better to use nums for the dates. and also I use dd-mm-yyyy format
kushalthakral
Creator III
Creator III

Hi Sheker

 

You can use union (+) in set analysis like below

=Sum({<ProductId = {'ProdA'}, SaleDate = {">=01/01/2016<01/03/2017"}> + <ProductId = {'ProdB'},SaleDate = {">=01/01/2018<=31/12/2018"}>}SaleAmount)

and output will be like below

 

Capture.PNG

I hope this answers your question

 

Thanks

Kushal