Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Ceb
Contributor III
Contributor III

Adding Rangesum Above to the Load Script

Hi,

 

DateValuesYear TargetMonthly TargetDaily Target
1/1/201903364227920
1/2/201945336422792132
1/3/2019127336422792265
1/4/2019174336422792398
1/5/2019174336422792398
1/6/2019174336422792398
1/7/2019237336422792531
1/8/2019301336422792664
1/9/2019368336422792797
1/10/2019419336422792930
1/11/20194793364227921063
1/12/20194793364227921063
1/13/20194793364227921063

 

 

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())))

(this considers the business days and start of the month and weekends)

 

 

The above works fine until a range of dates is selected. 

Assume I have filtered the dates between 7th Jan to 11th Jan

DateValuesYear TargetMonthly TargetDaily Target
1/7/201963336420132
1/8/2019127336420265
1/9/2019194336420398
1/10/2019245336420531
1/11/2019305336420664

 

I get the above table. I know the issue with the Monthly Target as I start with Day 1.

The main issue is with the Values. It changes as Rangesum considers the current filtered values.

 

I was thinking of moving the formulas to the Load Script and creating the table within the Load script. Is that possible?

I tried the formulas but I get an error using Rangesum and Above together in the Load Script

 

Would really appreciate if someone could help me out

Labels (3)
0 Replies