Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
danaleota1
Creator
Creator

Using RangeSum when there are nulls AND when none of the above rows are nulls within your range

Hello, 

For a pivot table I was asked to return the last three months average Quality Score when the month didn't have a quality score given.  I did this by using the an if statement with the rangesum(above()):

=if(IsCurrentMTD = '1', sum(WITNESS_POINTS_SCORED)/sum(WITNESS_POINTS_POSSIBLE), If(len(trim(sum(WITNESS_POINTS_SCORED)/sum(WITNESS_POINTS_POSSIBLE)))= 0 ,
RangeSum(Above(sum(WITNESS_POINTS_SCORED), 1,3))/RangeSum(Above(sum(WITNESS_POINTS_POSSIBLE), 1,3)), sum(WITNESS_POINTS_SCORED)/sum(WITNESS_POINTS_POSSIBLE)))

However there will be instances where there may also be nulls or no data in the preceding three months as well.  I need my expression to take the last three months that have data or are not null. How do I adjust my above expression to account for those scenarios?  Below is an example.  QA^^ is the field where I used RangeSum(Above)) for the Month of Jan-2021 it is giving the expected Quality Score a sum of points scored over points possible over the last three months, however, for month Feb -2021 its also taking the last three months but taking the Jan - 2021 month which is not what I want.  In the case for Feb -2021 where one of the preceding months also returns no data I want it to pull the preceding months where there is data.  **Also I don't want to apply this to the current month which I covered that in my if statement with IsCurrentMTD = '1' so that one is fine.  Any suggestions would be nice. Thank you. 

Dana

Month-YearQAQA^^Points ScoredPoints Possible
Jul-202099.13%99.13%573578
Aug-202098.68%98.68%673682
Sep-202098.36%98.36%480488
Oct-202097.95%97.95%383391
Nov-202098.11%98.11%467476
Dec-2020100.00%100.00%372372
Jan-2021-98.63%00
Feb-2021-98.94%00
Mar-2021100.00%100.00%378378
Apr-2021--00
0 Replies