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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
realpixel
Creator
Creator

sum expression

Hello,

I have following chart.

Nbre TA and Nbre T are an expression

I want to have in the field “RES” the result under

Someone have an idea to have the following result

18,75 = (3/16)*100

25= (4/16)*100

56,25=(9/16)*100

ZP

Nbre TA

Nbre T

CAM

LOC

RES

ZP

2

3

ALCL

-

18,75

ZP

3

4

SOCO

SOCO

25

ZP

5

9

SOCO

-

56,25

10

16

100

Labels (1)
17 Replies
realpixel
Creator
Creator
Author

The first expression returns, same value of NbreT

3

4

9

16

The second expression returns

362

362

362

362

Nicole-Smith
MVP
MVP

In your original post, you also have LOC field.  I think this also needs to be included in your aggr() and I was missing a set of parentheses on my other expressions:

(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2))/

sum(total aggr(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2),ZP,CAM,LOC))*100

I have also attached an example .qvw.

Not applicable

You can create a variable for the Nbre T expression. Call it vNbreT then in your RES expression use the following equation

=([Nbre T]/$(vNbreT))*100

This way the variable vNbreT will always be looking at the total of the Nbre T expression (16 in your example) creating an absolute reference to the total and the expression Nbre T will look at the pieces (3, then 4, then 9) of the total giving you the results you are looking for.

realpixel
Creator
Creator
Author

Hello,

1 - I try expression

(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2))/

sum(total aggr(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2),ZP,CAM,LOC))*100

But the result is always false, the result

0,828

1,104

2.486

If I use only a part of expression

sum(total aggr(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2),ZP,CAM,LOC))*100

The result is 36200 and not 1600 like example_2.qvw

2 - I try to create a variable vNbreT with expresionn contents in NbreT, like that

count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2)

But the result of =([Nbre T]/$(vNbreT))*100 gives me also a false value

500

400

1700

1600

Nicole-Smith
MVP
MVP

I think if you want help you need to post a .qvw

Preparing examples for Upload - Reduction and Data Scrambling

realpixel
Creator
Creator
Author

Hello Nicole,

I understand where does the problem.

I created an inline table to have only the "ZP" and in the demission ZP I have enable the option "Supress When value is Null" to have only the value "ZP"

If I disable option "Supress When value is Null" on "ZP" the total is 362

if I enable option "Supress When value is Null" on "ZP" the total is 16

The expression under does not ignores null values ​​and takes the total amount (362)



sum(total aggr(count({<ISO={'20'}>}distinct HMCONT) + (count({<ISO={'40'}>}distinct HMCONT)*2),ZP,CAM,LOC))*100

There is a possibility with this expression to ignore null value if the option "Supress When value is Null" is enable on ZP dimenssion?

Nicole-Smith
MVP
MVP

The following will make sure there is something in the ZP field (makes sure the length is at least one character):

sum(total aggr(count({<ISO={'20'},ZP={'?*'}>}distinct HMCONT) + (count({<ISO={'40'},ZP={'?*'}>}distinct HMCONT)*2),ZP,CAM,LOC))*100

realpixel
Creator
Creator
Author

Well done, it works perfectly now