Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Date | Values | Year Target | Monthly Target | Daily Target |
1/1/2019 | 0 | 33642 | 2792 | 0 |
1/2/2019 | 45 | 33642 | 2792 | 132 |
1/3/2019 | 127 | 33642 | 2792 | 265 |
1/4/2019 | 174 | 33642 | 2792 | 398 |
1/5/2019 | 174 | 33642 | 2792 | 398 |
1/6/2019 | 174 | 33642 | 2792 | 398 |
1/7/2019 | 237 | 33642 | 2792 | 531 |
1/8/2019 | 301 | 33642 | 2792 | 664 |
1/9/2019 | 368 | 33642 | 2792 | 797 |
1/10/2019 | 419 | 33642 | 2792 | 930 |
1/11/2019 | 479 | 33642 | 2792 | 1063 |
1/12/2019 | 479 | 33642 | 2792 | 1063 |
1/13/2019 | 479 | 33642 | 2792 | 1063 |
I have a visualization which has the following table
The date is calculated in the load script where missing dates are added using a calendar
Values is the sum(values) which I get from a table in the database table
Yearly Target is also a value from a database table
Monthly Target is calculated within the visualization using the below formula
round(RangeSum(above(If(Day = 1 ,(BusinessDays/(max(BusinessDaysYear))*SUM(distinct Target)), 0), 0, RowNo())))
(this considers the business days and start of the month)
Daily Target is calculated using the below formula
floor(RangeSum(Above(
if(weekday(dateenrolled)='Sat' or weekday(dateenrolled)='Sun' or HolidayValue=1,0,(BusinessDays/(max(BusinessDaysYear))*SUM(distinct Target))/BusinessDays)
, 0, RowNo())))
The above works fine until it is sorted. I have read that Above() function is interactive and does not work if the table is sorted.
I would like to know how should I go about solving this problem.
Thanks.
Aggr() by default sorts your data in the order the data was loaded... so for example if your Date is loaded like this
Date
1/1/2019 |
1/3/2019 |
1/2/2019 |
This will be the sorting that Aggr() will do.
But more recently, Qlik updated the Aggr() function to dynamically sorted. Check these links out
The sortable Aggr function is finally here!
Recipe for a Pareto Analysis – Revisited
First link will allow you to sort your Date on it's numeric value whereas the second one is more powerful (but I don't think you need it) where you can sort Date based on an expression.