Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

praveen1108
Contributor

If Else in Qliksense Expression

Hello All,

Can some one help me out whats wrong with this below if else . Default View logic is not working as it gives ' - ' instead of number.

Quick help will be really appreciated.

Regards,

PK

//Only Region

If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Region)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,Region={$(=concat(DISTINCT chr(39) & Region & chr(39),','))}>} Noofevents),

//Only Group

If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Group)=1 and GetSelectedCount(Region)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,Group={$(=concat(DISTINCT chr(39) & Group & chr(39),','))}>} Noofevents),

//Only Org

If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Org)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Region)=0 and  GetSelectedCount(Customer)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,Org={$(=concat(DISTINCT chr(39) & Org & chr(39),','))}>} Noofevents),

//Only Customer

If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Customer)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Region)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,Customer={$(=concat(DISTINCT chr(39) & Customer & chr(39),','))}>} Noofevents),

//Quarter and Region

If(GetSelectedCount(QuarterFormat)=1 and GetSelectedCount(Region)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<Region={$(=concat(DISTINCT chr(39) & Region & chr(39),','))}>} Noofevents),

//Default View

If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Region)=0 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,DataCategory = {'Global Lam Research'},Region = {'Lam Research'}>} Noofevents),

//Quarter and Group

If(GetSelectedCount(QuarterFormat)=1 and GetSelectedCount(Group)=1 and GetSelectedCount(Region)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<Group={$(=concat(DISTINCT chr(39) & Group & chr(39),','))}>} Noofevents),

//Quarter and Org

If(GetSelectedCount(QuarterFormat)=1 and GetSelectedCount(Org)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Region)=0 and  GetSelectedCount(Customer)=0,

max({<Org={$(=concat(DISTINCT chr(39) & Org & chr(39),','))}>} Noofevents),

//Quarter and Customer

If(GetSelectedCount(QuarterFormat)=1 and GetSelectedCount(Customer)=1 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Region)=0,

max({<Customer={$(=concat(DISTINCT chr(39) & Customer & chr(39),','))}>} Noofevents),Max(Noofevents) )

))))))))

5 Replies
MVP
MVP

Re: If Else in Qliksense Expression

Have you tested each single expression and it works? Troubleshooting a big expression can be simplified by breaking down into pieces. If possible share a sample with the expected output

praveen1108
Contributor

Re: If Else in Qliksense Expression

Yes i had tested this and Default view expression is the culprit and trying to figure out why....The one i have shared above is the actual expression that has been used.

MVP
MVP

Re: If Else in Qliksense Expression

By sample I meant your application

MVP
MVP

Re: If Else in Qliksense Expression

I vaguely remember some issues in Sense with lengthy expressions and nested if(), not sure if this might also cause your issue.

Just to clarify:

- All other conditions work as expected when you select e.g values in Region, Org, Customer?

- The only condition that is not working correctly is you default view, no selections made?

- Using this as single expression e.g. in a KPI object does return a number?

=If(GetSelectedCount(QuarterFormat)=0 and GetSelectedCount(Region)=0 and GetSelectedCount(Group)=0 and GetSelectedCount(Org)=0 and  GetSelectedCount(Customer)=0,

max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,DataCategory = {'Global Lam Research'},Region = {'Lam Research'}>} Noofevents)

)

If not, using this as single expression does return a number?

=max({<YearOfData={'$(=Max(YearOfData))'} ,QuarterOfData = {'All'} ,DataCategory = {'Global Lam Research'},Region = {'Lam Research'}>} Noofevents)

If not, you do actually have records for Noofevents when making selections in the fields stated in the set analysis with given values? And these records show numbers that can be aggregated using Max()?

As Sunny already asked for, if you still can't make it work, post a sample QVW.

There are too many unknowns to give a solid answer.

praveen1108
Contributor

Re: If Else in Qliksense Expression

Hi swuehl,

Yes for both the expressions that you mentioned above returns a value and if i use the entire expression then it is returining me nothing..

PK