Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
JohnnyUtah
Contributor II
Contributor II

Incorrect Percentage Total in straight table

Hi,

I have a straight table consisting of 6 dimensions and six measures.

% Spend is simply Days Logged / Demand (Days), so I'm expecting the % Spend below to be 41.7%

% Spend is a master object formatted as %.

In the % spend column Total Function is set to Auto. 

I'm fairly new to Qlik so expect there is an easy answer to this.

 

JohnnyUtah_0-1720551438674.png

Thanks in advance

Labels (1)
3 Replies
Scotchy
Partner - Creator
Partner - Creator

The issue you're facing with the % Spend calculation in the total line of your Qlik Sense table is likely due to how the Auto total function works for percentages. Instead of calculating the total percentage as the sum of individual percentages, you want it to calculate the percentage based on the total values.

Here's how you can resolve this:

  1. Create a new measure for the total % Spend:

    • Go to the "Master Items" and create a new measure for % Spend if you haven't already.
    • Use the expression Sum([Days Logged]) / Sum([Demand (Days)]).
  2. Use the newly created measure in your table:

    • Replace the current % Spend measure in your table with the new measure you created.

This way, the total % Spend will be calculated based on the total values of Days Logged and Demand (Days), ensuring the total line shows the correct percentage.

Steps to Create a New Measure:

  1. Go to the "Master Items" panel on the left.
  2. Click on "Measures" and then on the "+" icon to create a new measure.
  3. Name the measure, for example, Total % Spend.
  4. Enter the expression:
    Sum([Days Logged]) / Sum([Demand (Days)])
  5. Set the number formatting to "Number" and format as a percentage.

Replace the Measure in the Table:

  1. Edit your table.
  2. Remove the current % Spend measure.
  3. Add the newly created measure Total % Spend.

This should correct the total percentage calculation in your table.

JohnnyUtah
Contributor II
Contributor II
Author

Hi,

thanks for the reply. I've tried your suggestion but it does not fix the issue. I think the issue is that my % Spend master measure is derived from two other master measure items:

My % Spend master item is derived from two other master items:

Days Logged = Sum(clockify_hours_logged/vWorkingHours)

Demand (Days) = If(GetSelectedCount(period)=0, max(sd_demand)
,If(GetSelectedCount(period)>0, (max(sd_demand)/12)*GetSelectedCount(period)))

 

I then create my % Spend master item

% Spend = Days Logged / Demand (Days)

Qlik will not allow me to create a master items which sums these:

sum(Days Logged) / Sum (Demand (Days)

I don't think you can create master item which sums up other master measures.

 

Regards

Paul

 

 

 

 

Scotchy
Partner - Creator
Partner - Creator

Hi

Maybe try this approach...

You're correct that Qlik Sense does not allow you to create a master measure that aggregates other master measures directly. However, you can create the necessary aggregation in your table's measure directly.

To achieve the correct total calculation for % Spend, you can use a measure that performs the necessary calculations directly within the table. Here’s how you can proceed:

  1. Edit your table:

    • Go to the properties panel of your straight table.
  2. Add a new measure:

    • Click on "Add measure."
    • In the expression editor, use the following expression:
       
      Sum(Aggr(Sum(clockify_hours_logged/vWorkingHours), [Your Dimensions])) /
      Sum(Aggr(
        If(GetSelectedCount(period)=0, max(sd_demand),
        If(GetSelectedCount(period)>0, (max(sd_demand)/12)*GetSelectedCount(period))),
        [Your Dimensions]
      ))
    • Replace [Your Dimensions] with the dimensions used in your table.
    •  
  3. Format the measure as a percentage:

    • Set the number formatting to "Number" and choose "Percentage."

This approach uses the Aggr function to calculate the Days Logged and Demand (Days) for each dimension combination and then aggregates these values to get the correct total percentage.