Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
priyarane
Specialist
Specialist

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
JordyWegman
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:

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

 

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

Jordy

Climber

Work smarter, not harder
marcus_sommer

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