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

P() & E() Set analysis

The below is my Data Model.Vistis are joined to Charges table by Account ID.

Charges Table is joined to Calendar on POST DATE.

I have created an Independent Calendar to do the analysis.

Here is the problem,

When user selects a month from independent calendar, I want to fetch the same month from DISCH_MONTH_NM(Visit Table) and then fetch the possible Account IDs & then Calculating the Quantity for all those Accounts.

Data Model.png

In the UI Level , I created a Straight table like this.

Tableview.png

1st Expression : Only(MONTHNAME)  -- to Check weather it is fetching one value

2nd Expression : COUNT(DISTINCT if(MONTHNAME=DISCH_MONTH_NM, [Account ID]))  -- To check the number of Account IDs

3rd Expression : sum({<[Account ID]=P({<DISCH_MONTH_NM ={'$(=only(MONTHNAME))'}>}[Account ID])>} QUANTITY)  -- To fetch Quantity

But the 3rd Expression is not working...

Can any one correct this expression?

12 Replies
rubenmarin

Hi Jhansi, $-expanded expressions and set analysis are calculated for the whole table, not row by row. QV tries to expand the $-expression and it found different values for MONTHNAME so it returns null.

If you hover the mouse over the column title you'll see something like:

sum({<[Account ID]=P({<DISCH_MONTH_NM ={''}>}[Account ID])>} QUANTITY)

The 'If' version is calculated row by row.

rubenmarin

Btw, not tested (maybe later I have time to test and improve performance) but it can be something like:

Sum(if(MONTHNAME=DISCH_MONTH_NM, QUANTITY))

A sample would be nice to return a tested answer.

swuehl
MVP
MVP

You probably just need to copy the possible values from your data island to the Visits  table month field:

=Sum({<DISCH_MONTH_NM = p(MONTHNAME) >} QUANTITY)

hic
Former Employee
Former Employee

There could be a problem with the formatting of the month... If so, you may consider formatting both months as integers and use these in the set analysis. Do the DISCH_MONTH_NM and MONTHNAME have the same format?

But first: What does your label show? Here you can see if the dollar-expansion has worked the way you want.

Image3.png

Further, why do you keep the calendar as a logical island. I think a canonical date would be better. See Canonical Date.

HIC

Not applicable
Author

Yes. What you have explained is correct. It could not fetch the Month Values from MONTHNAME (Master table).

So What should be the right expression to reflect the value?

Thank you for responding.

Not applicable
Author

This is not working properly.

Tableview1.png

Not applicable
Author

This is working in a Text Object and giving the right result as shown in screen shot.

But giving the total amount for all the values.Tableview1.png

Not applicable
Author

Thank you Henric for responding. As you stated. the expression that i have written is giving output as below screenshot.

Instead of using $(=only(DISCH_MONTH_NM)) , I should use some expression to pull the correct month. Could you make a suggest? Thanks a lot in advance.

Tableview2.png

Not applicable
Author

Can any one have an idea?