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: 
ninawang99
Contributor
Contributor

Rangesum from specific rows

Hi Team,

My dataset was like 

Year Count({<Statu] = {'Active'} Emp_ID)
2000 20
2001 9
2002 48
2003 54
2004 95
2005 65
2006 53
2007 57
2008 77
2009 23
2010 100
2011 47
2012 53
2013 30
2014 69
2015 63
2016 38

 

 

The second column is how many new employees started in that year. I would like to create a line chart, X axis is Year and Y axis is the total active employees in that year, so the results should be like below

Year Count({<Statu] = {'Active'} Emp_ID) Active Emp
2000 20 20
2001 9 29
2002 48 77
2003 54 131
2004 95 226
2005 65 291
2006 53 344
2007 57 401
2008 77 478
2009 23 501
2010 100 601
2011 47 648
2012 53 701
2013 30 731
2014 69 800
2015 63 863
2016 38 901

 

But I only want to check dtaa after 2010 , do I use if(Year >= 2010, Year) as Dimension, and use 

rangesum(above( count({<Status= {'Active'}, Year = {">=2010"}>} Emp_ID), 0, RowNo()))

as measure.

But the results are not correct, as in 2010, the number is 100 instead if 601

 

can you please assist with that?

Many thanks

Labels (4)
1 Reply
Chirantha
Support
Support

Hey Nina,

 

If I understand it correctly, it seems like the issue with your current approach is that the ''above'' function only looks at the rows above the current row in the chart, not in the underlying data. Since you’re using if(Year >= 2010, Year) as your dimension, the chart only includes rows where the year is greater than or equal to 2010. This means that the ''above'' function only looks at rows where the year is greater than or equal to 2010, and doesn’t include the data from previous years.


To get the correct result, I think you need to include all years in your chart, not just those greater than or equal to 2010. You can do this by using ''Year'' as your dimension instead of if(Year >= 2010, Year). Then, you can use a set analysis expression to limit the data used in your measure to only include years greater than or equal to 2010