Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ziabobaz
Contributor II

p() as dimension

Hi,

I have:

I want to count numbers of SOLD orders which were CREATED in a period:

count(

{< Order= P({<status={'sold'}>})* P({<status={'created'}>}), status={'sold'} >}

DISTINCT Order

)

My period is august 2018 and the formula returns 1 (Order '300'), which is correct.

Is there a way I can define a flagCreated,

- when selected, the formula remains the same

- when deselected, the formula ignores P() function and returns 2 (Order 100 and order 300)?

The only wat I managed it by creating text variable, which returns P() when selected and returns nothing when deselected, so i subsequently put this varianle into the formula above, but is there a more elegant way?

Thank you

5 Replies
ziabobaz
Contributor II

Re: p() as dimension

Screenshot_10.jpg

MVP
MVP

Re: p() as dimension

Is there a way I can define a flagCreated,

- when selected, the formula remains the same

- when deselected, the formula ignores P() function and returns 2 (Order 100 and order 300)?

What is selected or deselected here?

ziabobaz
Contributor II

Re: p() as dimension

a field, a button, something... essence

i want to create it so i can select it

i will try to clarify

in the load script:

Load

Date,

Order,

if (status='created', 1,0) as flag;

So when i select 1 later in the front end, it shows only created order in the given time frame.

But this flag is static, so when the period changes, the flag also should change, therefor I have to use P()

the question is - is it possible to avoid using P() ?

MVP
MVP

Re: p() as dimension

Not sure I am able to follow your question here...

Re: p() as dimension

Based on your provided table-snippet I could imagine to add the created period to the sold-record of an Order, for example with something like this:

t:

load Date, Order, status from source;

     left join(t)

load Order, 'sold' as status, monthname(Date) as period_X

resident t where status = 'created';

By selecting your wanted periods within period_X and an expression like count(distinct Order) should return your needed numbers.


- Marcus

Community Browser