Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
timetraveler
Contributor II
Contributor II

Using the P() function

Hi,

The set expression editor is giving me an error when I try to use the P() function in this way:

sum({$ < FIELD_1 = {$1}, FIELD_2 = {$2}, Period = P($3) > } Amount)

I'm "calling" this like:

vFunction(A,B,Q1) , vFunction(A,B,Q2)...

So the third parameter $3 is changing, as it's a date. Q1 and Q2 are text(date#) format and
Period is a date format. So the expression does what I want, but it's giving me an error and I would like to write it properly.

 

Thank you

 

5 Replies
marcus_sommer

Are Q1 and Q2 fields within your datamodel? Further comparing real dates with strings will only work in some very specific cases and should be therefore in general avoided.

- Marcus

timetraveler
Contributor II
Contributor II
Author

Hi, thanks for the reply, yes they are fields. I made them this text format while I was testing something. I can make them into a date again. The main point is that if I write:

 

Period = P(Q1),

there will be no error.

But if I write P($3), there is an error...

marcus_sommer

Try it in this way: vFunction(A,B,[Q1])

- Marcus

timetraveler
Contributor II
Contributor II
Author

Hi, the call of the function (within a master item) is not causing an error. It's the function itself (where P($3)) .  I tried with P([$3]) and all kinds of different brackets but I guess I didn't find the right one, or it's a bug in the expression checker itself.

marcus_sommer

If it's worked you could ignore the expression checker which is a good indicator but is independent from the executing engine and therefore not mandatory the truth.

- Marcus