Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
Showing results for 
Search instead for 
Did you mean: 

P() in script

Hello All,

how we can do it P() functionality in Script level.

For an ex:

Sum({<TDate = P(PDate), Tdate=>}Sales)


Thank you.

2 Replies
Partner - Master
Partner - Master

Hi Priyarane,

P() is a chart function so this is not going to work. For this to work you need to add the PDate to the table of Sales and TDate.

If this is already in the same table, use this:

   Sum( Sales ) as Sales
From [YourSource]
Where TDate = PDate
Group by TDate, PDate


This will give your all the sales where TDate equals PDate.



Work smarter, not harder
MVP & Luminary
MVP & Luminary

Like already mentioned it's an UI feature and not available within the script. But you could emulate the behaviour with exists(), like:

t: load ID, sum(Sales) * -exists(PDate, TDate) as Sales from Source group by ID;

but like all accesses on the system-fields you could it only apply by a single condition - not like by p() which could contain own conditions and/or be nested by more complex queries. Further you need to consider the load-order in the script because the related fields must be already loaded and appropriate named.

Of course with some adjustments you may also get more complicated scenarios to work and therefore the suggestion from Jordy is probably the more practically direction in regard to a general approach.

- Marcus