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: 
Not applicable

Quartiles by Using an IF Statement

Hi,

I have a straight table which displays date, IM, and another calculated expression.

There is also a field loaded called EOY (month) and another one EOY_NO (month number).

I need to display the four highest IM for each yearly quartile which depends on EOY. So if EOY field is March, the highest value has to be displayed for a quartile after March which would be April, May and June. EOY is different for each company that can be selected. Then 3 more values have to be displayed for the rest of quartiles.

Any suggestions?

I used this method which worked if EOY was the same for all the companies, e.g. for Quartile 2 (I had separate tables for each quartile):

if(month(DATE) > 2 and month(DATE) < 6), sum(IM))

1 Solution

Accepted Solutions
Not applicable
Author

Used variables for dates and multiplied by 0.25, 0.5 etc for each quartile

View solution in original post

5 Replies
sushil353
Master II
Master II

Please post sample data or sample app

Not applicable
Author

What it should look like:

DateIMNCRatio

Quarter 1 e.g. 26/02/2013

2001000=IM/NC
Quarter 2 e.g. 15/05/20133001000
Quarter 35001000
Quarter 42001000
Current Date2001000

EOY - End of Year
5
12 - applies for the selected company

So lets say for the above example, Company A, EOY is December as can be seen from the table. This means that Q1 would include January, February and March. I need to display the highest IM amount for that quarter. I need to do this for every quarter.

EOY might be different for Company B, it might be March or any other month so automatically quarter months would be different.

Hope this makes sense

Not applicable
Author

Changed the expression to:

if

     (DATE > addmonths(today(),-12),

if(

(

     EOY < 7

     AND

     month(DATE) < EOY + 7

     AND

     month(DATE) > EOY + 3

      )

OR

      (

     EOY = 7

     AND

     month(DATE) > 10

     OR

     month(DATE) = 1

      )

OR

      (

     EOY = 8

     AND

     month(DATE) < 3

     OR

     month(DATE) = 12

      )

OR

      (

     EOY > 8

     AND

     month(DATE) < EOY - 5

     AND

     month(DATE) > EOY - 9

      ),          

sum(IM),

'no data')

)

This is for Q2, but it still shows 1 (Jan) data when EOY is 12 (Dec). It doesn't meet the conditions though to be displayed.

Is my statement correct? Why is Jan data displayed in Q2 results?

Not applicable
Author

Anyone have any ideas about this?

Not applicable
Author

Used variables for dates and multiplied by 0.25, 0.5 etc for each quartile