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: 
rish
Contributor III
Contributor III

Line graph doesnt count total to date

Hi I am using data which kinda looks like this:

category         week

1                        1

2                        1

1                       3

1                       4

2                       6

Now, I want a line graph that shows percentage of 2's.

so for week 1 - 50%, week 2 - 50%, week 3 - 33.33%, week 4 - 25%, week 5 - 25%, week 6 - 40% and so on. The values I am currently getting are:

 

week 1 - 50%, week 2  -0%, week 3 - 0, week 4 - 0 week 5 - 0, week 6 - 100%

 

can this be done? Thanks!

 

1 Solution

Accepted Solutions
anseglko
Creator
Creator

Okay now I get it. You need cumulative sums with rangesum(above())

 

Try this as measure with week as dimension:

RangeSum(Above((count(if(category = 2,1))),0,RowNo()))
/RangeSum(Above(count(if(category,1)),0,RowNo()))

 

View solution in original post

4 Replies
Shubham_Deshmukh
Specialist
Specialist

Can u explain a bit more about your calculation condition? How do you want 50% for 2's ?

rish
Contributor III
Contributor III
Author

i assume you are getting confused over the week 1 values. there are 2 entries for week 1, but only one of them is category 2, thats why i get 50% in that. in week 2 there are no new entries so the value remains 50%. In week 3 an entry is added in category 1, now the total no. of entries will be 3, and only one of them will be of category 2, hence 33.33% and so on.

anseglko
Creator
Creator

Okay now I get it. You need cumulative sums with rangesum(above())

 

Try this as measure with week as dimension:

RangeSum(Above((count(if(category = 2,1))),0,RowNo()))
/RangeSum(Above(count(if(category,1)),0,RowNo()))

 

rish
Contributor III
Contributor III
Author

thanks mate!!!