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: 
Not applicable

How calculate the percentage?

Hi all,

I have one scenario:

load * Inline
[
year,month,visits
2007,1,20
2007,2,30
2009,1,30
]

I want to calculate the pecentage, it looks like this:

Year Month Visits Percentage

2007 1 20 20/50

2007 1 30 30/50

2009 1 30 30/ 30

It means how many percentage the month visits occupied based on the same year.

I want to use pivot table to achieve, how to write this expression?

Thanks.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Isaac,

Create a new chart, pivot table, set year and month (in that order) as dimensions.

Use the following expression:

Sum(visits) / Sum(TOTAL <year> visits)


In the "Number" tab, set it to %

Hope that helps.

View solution in original post

10 Replies
Not applicable
Author

If I understood correctly how you want to display your ratio/percentage, this should help.

Not applicable
Author

just calculate the number of visits by year in the script, you will be able to do calculations very easily :



load

year, sum(visits) as visitsByYear resident yourTable group by year

;





Miguel_Angel_Baeyens

Hello Isaac,

Create a new chart, pivot table, set year and month (in that order) as dimensions.

Use the following expression:

Sum(visits) / Sum(TOTAL <year> visits)


In the "Number" tab, set it to %

Hope that helps.

Not applicable
Author

Could you paste the code directly, because I just have named cal. thantks

Not applicable
Author

sum(visits) & '/' & sum(total <year> visits)

tresesco
MVP
MVP

try this:


=Sum(visits)/Sum(total <year> visits)


Hope this helps.

regards, tresesco

Not applicable
Author

Thanks,it works. But I want to know the meaning of it.

I know total means get the whole visits. But what's the meaning of <year> ?

tresesco
MVP
MVP

<year> says about the totaling dimension. means get the whole visits...YEARLY.

Not applicable
Author

So all the dimension can be used after total, right?

It means <Dim> is a part of total, right?

Sorry, and total <year> is not a set analysis, do I understand right?

Sorry to disturb you again.