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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need expression to calculate percentages for my dims

Hi,

I have a below table and I would like to calculate percentages for my dimesions. The problem is, I have amounts in both Positive and negatives and I need to use Fabs() to get them into positive at dimension level summarization.

Ex:

Field1, Amount

aaa, -200

aaa, 50
bbb, 300

bbb, -100

Expected results to calculate percentage by using Bar Chart:

aaa, 42.5%     (150/350)

bbb, 57.1%     (200/350)

Thanks in advance.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

Dim               Field1

Expression     fabs(sum(Amount)) / sum(total fabs(aggr((sum(Amount)), Field1)))

View solution in original post

6 Replies
MK_QSL
MVP
MVP

Please check enclosed file..

MK_QSL
MVP
MVP

Create a Bar Chart...

Dimension = Field1

Expression : FABS(SUM(Amount)/SUM(TOTAL{<Amount = {'>0'}>}Amount))

UPDATE :
Go to Number Tab and Tick Show in Percentage

maxgro
MVP
MVP

Dim               Field1

Expression     fabs(sum(Amount)) / sum(total fabs(aggr((sum(Amount)), Field1)))

Not applicable
Author

HI,

Dimension Field1,

fabs(sum(Amount)/sum(TOTAL {<Amount={">=0"}>}Amount)*100))

Not applicable
Author

Hi Manish,

Thanks for your reply. Probably, my example isnot clear i guess. You have used a conditon with Amount is > 0 in your SET expression. That is NOT I am looking for.

Take a look at another example:

Field1, Amount,

aaa, -200

aaa, 100

bbb, 300

bbb,-100

Expected:

aaa as 33.3%  (100/300)

bbb as 66.6% (200/300)

Thanks in advance.

Not applicable
Author

Thanks Grossi.