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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
taylor_jesse
Creator
Creator

Error in Expression

Hi,

I have an expression that included variables. I keep getting an error in expression but can't seem to find the issue.

=if(Loc_Status='ONG',sum(  $(Set60Days) IdealFlag)/Count(DISTINCT $(Set60Days) CalendarDate))


Variable description below:

Set60Days =  {$<CalendarDate = {">=$(v60Days) <=$(vMaxCalDate)"},OPS_MonthYear=>}

v60Days = AddMonths(max(CalendarDate),-2)

vMaxCalDate = max(CalendarDate)

1 Solution

Accepted Solutions
sunny_talwar

I keep getting an error in expression but can't seem to find the issue.

Is that your expression editor says that there is an error or do you see an error/ or see nothing when you click okay on the expression editor and look for the result in the object? The reason I ask this is because, there are times when expression editors don't really understand the syntax and will say that there is an error where there is none. In your case...

=if(Loc_Status='ONG',sum(  $(Set60Days) IdealFlag)/Count(DISTINCT $(Set60Days) CalendarDate))

the part in red will def. throw an error in expression editor, but it may still work if the value within that variable is good... which it seems like is (syntax wise).

View solution in original post

6 Replies
vishsaggi
Champion III
Champion III

What value does your variable Set60Days display when you use $(Set60Days) can you try this in your text object and let me know.

And you cannot use $(Set60Days) in your sum like that. What exactly you are trying to do in your below expr?

I mean sum(IdealFlag) and what is this Set60days doing here are you multiplying ? or doing something else? You might need set analysis is what i think. Please elaborate a little more. 

=if(Loc_Status='ONG',sum( $(Set60Days) IdealFlag)/Count(DISTINCT $(Set60Days) CalendarDate))

poojashribanger
Creator II
Creator II

if(Loc_Status='ONG',sum(  {<$(Set60Days)>} IdealFlag)/Count({<$(Set60Days)>} DISTINCT CalendarDate))


enclose that variable in set analysis.

sunny_talwar

I keep getting an error in expression but can't seem to find the issue.

Is that your expression editor says that there is an error or do you see an error/ or see nothing when you click okay on the expression editor and look for the result in the object? The reason I ask this is because, there are times when expression editors don't really understand the syntax and will say that there is an error where there is none. In your case...

=if(Loc_Status='ONG',sum(  $(Set60Days) IdealFlag)/Count(DISTINCT $(Set60Days) CalendarDate))

the part in red will def. throw an error in expression editor, but it may still work if the value within that variable is good... which it seems like is (syntax wise).

taylor_jesse
Creator
Creator
Author

Same error

taylor_jesse
Creator
Creator
Author

Hi,

It shows values but the expression editor says there is an error. I think you are right. I experience that a lot.

taylor_jesse
Creator
Creator
Author

The expression works but the editor says error in expression