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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Total month sum in a pivot table

Hello Friendlies,

I've tried many o things but I can't seem to get it to work. In the percent column I'm trying to do the following: the (amount for the day / total amount for the month). I'm having difficulties getting total month formula to work properly.

Here is my formula for the amount for that day:

sum( {$<OeTyp={"S","W"},OrdTyp-={"4"}> }Tot_Invoice - (TotFedTax-TotSalesTax))

error loading image

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Well, if your Month values don't include the year in them (mine normally do), you'd need to do <Year, Month> instead of just <Month>. But that's probably not the problem, since you'd have smaller numbers than expected if that was the problem, not larger. With that corrected, I'm getting good numbers for the attached sample file.

(Edit: Ah, I missed that you have Branch in there as a dimension as well, and you called year FY. So I'd think you'd want <FY, Month, Branch> in the total expression.)

View solution in original post

5 Replies
johnw
Champion III
Champion III

Well, for simplicity, let's say your Amount expression was just sum(Amount). Then the percentage of the total for the month would be sum(Amount)/sum(total <Month> Amount).

So I THINK that for your actual case, you'd want this:

sum( {<OeTyp={"S","W"},OrdTyp-={"4"}> }Tot_Invoice - (TotFedTax-TotSalesTax))
/sum(total <Month> {<OeTyp={"S","W"},OrdTyp-={"4"}> }Tot_Invoice - (TotFedTax-TotSalesTax))

Not applicable
Author

Thanks for your reply,

but that's giving a very large number for Total Month Amount and the amount is the same for every month.

johnw
Champion III
Champion III

Well, if your Month values don't include the year in them (mine normally do), you'd need to do <Year, Month> instead of just <Month>. But that's probably not the problem, since you'd have smaller numbers than expected if that was the problem, not larger. With that corrected, I'm getting good numbers for the attached sample file.

(Edit: Ah, I missed that you have Branch in there as a dimension as well, and you called year FY. So I'd think you'd want <FY, Month, Branch> in the total expression.)

Not applicable
Author

John,

that's beautiful! You were right on the money on that. I've never really use the SUM TOTAL expression before and I thought SUM would already take into the account the dimensions in the table.

johnw
Champion III
Champion III

Sum() DOES take into account ALL dimensions in the table. Sum(total ...) IGNORES all dimensions in the table. But in your situation, you wanted to take some dimensions into account, but not others. Fortunately, sum(total ...) lets you specify which dimensions you want to account for (something I kept forgetting for my first year or two of QlikView).