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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Percent to Subtotals

Hello -

I am relatively new to QlikView and have been creating various reports. Many of my reports contain % to totals and % to subtotals.

Example:

StyleDescriptionUnits% To Total
ABC1Full Coverage Bra7535.71%
ABC2Full Coverage Bra5526.19%
ABC3Full Coverage Bra8038.10%
SUBTOTAL21061.76%
ABC4Demi Bra9573.08%
ABC5Demi Bra3526.92%
SUBTOTAL13038.24%
Total Bra340


How do I replicate all above percentages in QlikView 9.0?

1 Solution

Accepted Solutions
Not applicable
Author

You may be able to use dimensionality. Dimensionality is designed to return the aggregation level of an expression total. In the example above, Dimensionality() in its own expression would return 1 on the row for Total Bra, 2 on the subtotal rows for each bra type, and 3 for the lowest level bra type/style data. That said, you could write your expression to run different expressions based on their aggregation level like this (using pick to avoid nesting ifs):

pick(dimensionality(), null(), Sum(Units)/Sum(TOTAL Units), Sum(Units)/Sum(TOTAL <Description> Units))

In this case, I used pick to select the appropriate formula from the ordered list using the returned aggregation level from dimensionality.

View solution in original post

8 Replies
boorgura
Specialist
Specialist

In the expressions TAB - there is option to CHECK relative. That will make the values relative to the total and show it as a %.

Not applicable
Author

Thanks Rocky. This example is a pivot table, with subtotals, and the relative box isn't available for pivot tables. If I do as a straight table, and check relative, then I get just % to the Grand total and not % to Subtotal results, which is what I'm looking for. Any other suggestions?

Not applicable
Author

You may be able to use dimensionality. Dimensionality is designed to return the aggregation level of an expression total. In the example above, Dimensionality() in its own expression would return 1 on the row for Total Bra, 2 on the subtotal rows for each bra type, and 3 for the lowest level bra type/style data. That said, you could write your expression to run different expressions based on their aggregation level like this (using pick to avoid nesting ifs):

pick(dimensionality(), null(), Sum(Units)/Sum(TOTAL Units), Sum(Units)/Sum(TOTAL <Description> Units))

In this case, I used pick to select the appropriate formula from the ordered list using the returned aggregation level from dimensionality.

Not applicable
Author

This did the trick!!! Thank you 🙂

Not applicable
Author

Annel, what formula did you get?

I'm trying Aaron formula, but isn't work....

Thanks

Not applicable
Author

OK! IT WORKS!!

Thanks Aaron 😄

Not applicable
Author

Hi!

Is it possible to consider a dimension group? Instead of using a particular dimension (like, for example, "Units").

A group like --> Dimension Group (containing "Units", "Sales", "Salesman",...)

And each dimension of the group can apply the same calculation for the subtotals....

Thanks a lot!

Best Regards,

Adri

Not applicable
Author

Ok, I solve it!

Instead of consider the single dimension like:

pick(dimensionality(), null(), Sum(Units)/Sum(TOTAL Units), Sum(Units)/Sum(TOTAL <Description> Units))

Consider the dimensions group as follows:

pick(dimensionality(), null(), Sum(Units)/Sum(TOTAL Units), Sum(Units)/Sum(TOTAL <[Dim Group]> Units))

It works!!