# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Contributor II

## Need help to write an expression in the combination of alternate state and set analysis

Hello Experts,

I need a help to write the Expression. I have  a Expression something like this

=if(USD_ASP<>0 and ProductType = 'Recommended',Count({Selection1*Selection3}Product_Product_Id)),Count({Selection2*Selection3}Product_Product_Id)))

But this is accepting USD_ASP's Zero values. Can you guys please check this query and help me out from this.

Selection1, Selection2, Selection3 are alternate states

Labels (7)

• ### qlikview expressions

2 Solutions

Accepted Solutions
Partner

## Re: Need help to write an expression in the combination of alternate state and set analysis

=if(ProductType = 'Recommended',
Count({Selection1*Selection3<USD_ASP={'>0'}>}Product_Product_Id),
Count({Selection2*Selection3<USD_ASP={'>0'}>}Product_Product_Id))

are there any USD_ASP <0?

Partner

## Re: Need help to write an expression in the combination of alternate state and set analysis

you have 2 brackets in the first sum..

=if(ProductType = 'Recommended',Sum({{Selection1*Selection3<USD_ASP={">0"}>}USD_ASP),Sum({Selection2*Selection3<USD_ASP={">0"}>}USD_ASP))/
if(ProductType = 'Recommended',Count({Selection1*Selection3<USD_ASP={">0"}>}Product_Product_Id),Count({Selection2*Selection3<USD_ASP={">0"}>}Product_Product_Id))*ExchangeRate

remove 1 and see if that helps

7 Replies
Contributor II

## Re: Need help to write an expression in the combination of alternate state and set analysis

Can you guys Please have a look and help me out from this

Partner

## Re: Need help to write an expression in the combination of alternate state and set analysis

Hi, what is accepting zero values exactly, the else in the IF would accept zero values.

What exactly do you want the IF statement to do?

Contributor II

## Re: Need help to write an expression in the combination of alternate state and set analysis

Hi,

I want to show the count (Product_product_Id) where USD_ASP <>0 by using alternate states

can you please modify that expression.

Partner

## Re: Need help to write an expression in the combination of alternate state and set analysis

=if(ProductType = 'Recommended',
Count({Selection1*Selection3<USD_ASP={'>0'}>}Product_Product_Id),
Count({Selection2*Selection3<USD_ASP={'>0'}>}Product_Product_Id))

are there any USD_ASP <0?

Contributor II

## Re: Need help to write an expression in the combination of alternate state and set analysis

It is some thing working, But my total expression is this. if write this expression it is showing error in expression

Can you please check for this once

=if(ProductType = 'Recommended',Sum({{Selection1*Selection3<USD_ASP={">0"}>}USD_ASP),Sum({Selection2*Selection3<USD_ASP={">0"}>}USD_ASP))/
if(ProductType = 'Recommended',Count({Selection1*Selection3<USD_ASP={">0"}>}Product_Product_Id),Count({Selection2*Selection3<USD_ASP={">0"}>}Product_Product_Id))*ExchangeRate

Partner

## Re: Need help to write an expression in the combination of alternate state and set analysis

you have 2 brackets in the first sum..

=if(ProductType = 'Recommended',Sum({{Selection1*Selection3<USD_ASP={">0"}>}USD_ASP),Sum({Selection2*Selection3<USD_ASP={">0"}>}USD_ASP))/
if(ProductType = 'Recommended',Count({Selection1*Selection3<USD_ASP={">0"}>}Product_Product_Id),Count({Selection2*Selection3<USD_ASP={">0"}>}Product_Product_Id))*ExchangeRate

remove 1 and see if that helps

Contributor II

## Re: Need help to write an expression in the combination of alternate state and set analysis

Thank you very much for the solution. It's working Now