Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
profilejamesbond
Creator II
Creator II

Qlik Sense Expression not working

Hi,

I have this Set Analysis but it is not working because the if condition is not working and always executing the else section. The problem seems to me is, the if condition is returning multiple values therefore, the true condition is not executed and directed to execute else block of code.

How to fix this thing ?

 

=if(Month(Date) = month(today()-1) and Year(Date) = year(today()-1),

sum({<field={0}>}field1), sum({<field={0}>}field2))

 

Thanks

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

You could try using a more pure set analysis approach to solve this. 

Something like this:

sum({<field = {0}, Date = {">=$(=MonthStart(Today(), -1)) <=$(=MonthEnd(Today(), -1))"}>} field1)

+

sum({<field = {0}, Date -= {">='$(=MonthStart(Today(), -1))' <='$(=MonthEnd(Today(), -1))'"}>} field2)

View solution in original post

3 Replies
robert_mika
Master III
Master III

Are you using this condition in KPI or table object?

Do you have a date that is corresponding to the yesterday?

What selections are you making in the filters?

HirisH_V7
Master
Master

It seems your date may not be evaluating correctly against the specified conditions. Try checking each condition separately to see what result it produces.

HirisH
Vegar
MVP
MVP

You could try using a more pure set analysis approach to solve this. 

Something like this:

sum({<field = {0}, Date = {">=$(=MonthStart(Today(), -1)) <=$(=MonthEnd(Today(), -1))"}>} field1)

+

sum({<field = {0}, Date -= {">='$(=MonthStart(Today(), -1))' <='$(=MonthEnd(Today(), -1))'"}>} field2)