Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

calculate the percentage of total (beräkna andel av total)

How do I calculate a% stake per line compared to a total

Example

Total 150

Line 1 15 = 10%

Line 2 D 25 = 16.6%

Rad 3:05 a.m. = 3.3%

Series 4105 = 70%

The term I use the sum and get a total in the table but I want a new column with% s per line

Translated with Google Translate - Qlik Community Administrative Team

Hur beräknar jag en % andel per rad i förhållande till en total

Exempel

Total     150

Rad 1     15 =10%

Rad 2     25  =     16,6%

Rad 3     5 =      3,3%

Rad 4     105 =     70%

I uttrycket använder jag sum och får en total i tabellen men jag vill ha en ny kolumn med % talet per rad

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Om du har ett fält som heter Belopp som du vill göra beräkningen på, och detta skall göras i en pivottabell, så kan du använda följande som formel:

     Sum( Belopp ) / Sum( Total Belopp )

Täljaren kommer att vara olika på all rader (15, 25, etc) medan nämnaren kommer att vara 150 överallt. Sedan är det bara att formatera som procent på Nummerfliken i pivottabellens egenskaper.

Du skall inte använda ALL då den gör något annat: Den nonchalerar även alla val du gjort, och det tror jag inte du vill.

HIC

View solution in original post

6 Replies
oknotsen
Master III
Master III

Translation (by Google translate):

How do I calculate a% stake per line compared to a total

The term I use the sum and get a total in the table but I want a new column with% s per line

Sorry, I do not speak Swedish, so you have to do with English .

I assume "Rad" is the name of the value.

Two options, depending on your need:

- Make the 2nd column a copy of the first column (use "=column(1)" for example) and select "relative" (found in the exact middle of the Expression tab)

- Add this expression to the 2nd column: = sum(Rad)/sum(ALL Rad)

Hope this helps.

May you live in interesting times!
Not applicable
Author

Hello

Thank you

the little word ALL helped me a lot....

Best regards

Lennart S

Från: Onno van Knotsenburg

Skickat: den 24 juni 2015 13:47

Till: Lennart Stenius

Ämne: Re: - beräkna andel av total

hic
Former Employee
Former Employee

Om du har ett fält som heter Belopp som du vill göra beräkningen på, och detta skall göras i en pivottabell, så kan du använda följande som formel:

     Sum( Belopp ) / Sum( Total Belopp )

Täljaren kommer att vara olika på all rader (15, 25, etc) medan nämnaren kommer att vara 150 överallt. Sedan är det bara att formatera som procent på Nummerfliken i pivottabellens egenskaper.

Du skall inte använda ALL då den gör något annat: Den nonchalerar även alla val du gjort, och det tror jag inte du vill.

HIC

Not applicable
Author

Tack det funkade

Testade med ALL istället för TOTAL men då fick jag problem

//Lennart S

Från: Henric Cronström

Skickat: den 24 juni 2015 14:45

Till: Lennart Stenius

Ämne: Re: - beräkna andel av total

oknotsen
Master III
Master III

I agree with HIC (no real surprise there): It depends on what you want to achieve if you should use ALL or TOTAL.

Check with your customer and test to see what fits you(r customer) most .

May you live in interesting times!
hic
Former Employee
Former Employee

I claim that you should never use the ALL qualifier. It is a legacy functionality that eventually will disappear.

If you want to disregard the dimensional grouping – Use the Total qualifier.

If you want to disregard the selection – Use {1} in Set Analysis

So, instead of ALL, you should use both {1} and Total.

See The Aggregation Scope.

HIC