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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Rashmi1
Contributor
Contributor

Sum at different levels - Qlik Sense

Hello,

I  have a strange requirement and wanting to see if anyone has a better solution to do this in the Qlik Sense load script rather than the front end because we might want to reuse this at multiple places.

Scenario:
I have a table with values as below:

Rashmi1_0-1777579954256.png


I need to calculate performance as total of all payments for a department (irrespective of the month) + credit for the month the user selects (max month).

Example: When user selects Jan 2025, Department A needs to have a total of all payments + Credit value for the month the user selected

In this case it would be 
Department A (Jan 2025) - 7800 + 100 = 8800

Is this even a possible thing to do in Qlik Sense? 

Labels (3)
1 Solution

Accepted Solutions
JR4
Contributor III
Contributor III

I think I might have a couple solutions based on your table. It looks like front-end or the master measure would make the most sense since the script option would still require you to add the expression as a measure.

1. Just front-end in your measure, or create as master measure to re-use in other apps
SUM({<Department=>} TOTAL [Payments]) + SUM([Credit])

2. In Script
MonthlyPayments:
LOAD
Month,
SUM(Payments) AS TotalPayments_Month
RESIDENT YourTable
GROUP BY Month;

LEFT JOIN (YourTable)
LOAD
Month,
TotalPayments_Month
RESIDENT MonthlyPayments;

Measure in table
SUM(TotalPayments_Month) + SUM(Credit)

View solution in original post

1 Reply
JR4
Contributor III
Contributor III

I think I might have a couple solutions based on your table. It looks like front-end or the master measure would make the most sense since the script option would still require you to add the expression as a measure.

1. Just front-end in your measure, or create as master measure to re-use in other apps
SUM({<Department=>} TOTAL [Payments]) + SUM([Credit])

2. In Script
MonthlyPayments:
LOAD
Month,
SUM(Payments) AS TotalPayments_Month
RESIDENT YourTable
GROUP BY Month;

LEFT JOIN (YourTable)
LOAD
Month,
TotalPayments_Month
RESIDENT MonthlyPayments;

Measure in table
SUM(TotalPayments_Month) + SUM(Credit)