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

Calculation across rows

Hi guys,

I'm looking to a better way to implement the calculation below.

What I need to calculate is the value in the last columns below.

Dimension 1Dimension 2Value% of A
XA100100%
XB5050%
XC3030%
YA200100%
YB5025%
YC4020%

The last column show the % of the value in the specific row compared to the value where dimension 2 is equal to 'A'.

I'm having issue calculating the denominator of my formula that should always be equal to the value measure when dimension 2 is  equal to A.

If I specify the denominator through Set Analysis as

SUM({<[Dimension 2]={'Gross Sales'}>} Value) I got the below


Dimension 1Dimension 2ValueDenominator
XA100100
XB50
XC30
YA200200
YB50
YC40


While I need to have 100 and 200 repeated on all rows.

If I use Total as SUM({Total<[Dimension 2]={'Gross Sales'}>} Value) I got the below


Dimension 1Dimension 2ValueDenominator
XA100300
XB50300
XC30300
YA200300
YB50300
YC40300


That is again wrong as  the total is done ignoring all dimension grouping.


I got it to work specifying the group by dimension for the total as follow SUM({<[Dimension 2]={'Gross Sales'}>} Total<[Dimension 1] Value) but i would  like to know if:

- There's any better way to express this as right now in my total I need to list all the dimensions excluding the one on which I'm applying the filter (Dimension 2 in the example)

- In case of many dimensions to group on and high volume of data there may be performance implications


Thanks

Andrea

7 Replies
annafuksa1
Creator III
Creator III

Can you post app ?

rubenmarin

Hi Andrea, I attach an example using above function, It will get the first row based on the last dimension, so if there is a Dimension after 'Dimension 2' probably won't meet your requirements.

Not applicable
Author

Thanks, but I fear is not going to work for more complex scenarios.

I created a small example but I'm not sure how I can upload it here.

Thanks

Andrea ! !

rubenmarin

When you're  answering, in the upper-right corner there is a link to advanzed editor:

From the you can upload files:

Not applicable
Author

Attached I created a small example.

In short I want to understand if there's a better way to calculate the denominator than the one I used in the "Denominator - Total Group By" expression as I don't like the idea of listing all my dimensions into the Total function.

Thanks

Andrea

rubenmarin

Hi Andrea, different approaches:

- the above function i told you before

- modification in script so there is the TOTAL value in each record

- using a variable to list the dimensions, playing with the value the variable should return you can work to make this more dynamic. (using concat if there is a field where user selects dimensions)

Hope any of this helps you.

Not applicable
Author

Thanks a lot Ruben, for providing some options.

I'll probably end up adding the data column to the script and use that in my calculation.

Andrea