Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum Total YTD (variable)


Hello,

I have created the following table:

ytd.PNG

Here the expression I have used for the "Cost %" for the current month

num(sum(Cost)/ Sum(total(Cost)), '#,0%')

My problem is with the expression I have created for the "Cost %" for the YTD:

num(sum({<vYTD>}Cost)/ Sum(total({$<$(vYTD)>}Cost)), '#,0%') 

What am I doing wrong? How can I calculate the percentage of the cost for the YTD? Or how can I calculate the total with a Variable?

Thank you in advance for your help!

Iuri

1 Solution

Accepted Solutions
sunny_talwar

I did not just change the number formatting, but also removed the parenthesis after TOTAL, did you try to remove that from your expression:

num(sum({<vYTD>}Cost)/ Sum(total({$<$(vYTD)>}Cost)), '#,0%')

View solution in original post

12 Replies
sunny_talwar

Give this a try:

Num(Sum({<vYTD>}Cost)/Sum(TOTAL {<$(vYTD)>}Cost), '#,##0.0%')

sunny_talwar

Actually how do you define your variable vYTD?

settu_periasamy
Master III
Master III

Hi,

What Contains your vYTD variable?

Not applicable
Author

Hello Sunny,

Thanks for your reply.

That does not work as well, even if the problem were the number format that would show any value, but all I get is '-'.

Not applicable
Author


Hello Settu,

Here whats inside the variable:

Month=,RelativeMonthID=, MonthID={"<=$(=Max(MonthID))"}, YearID={$(=Max(YearID))}

Thanks for your help.

sunny_talwar

What is this variable vYTD? Can you show the expression behind this variable? Is it working for YTD Cost???

sunny_talwar

I did not just change the number formatting, but also removed the parenthesis after TOTAL, did you try to remove that from your expression:

num(sum({<vYTD>}Cost)/ Sum(total({$<$(vYTD)>}Cost)), '#,0%')

Not applicable
Author

Here the Varible:

Month=,RelativeMonthID=, MonthID={"<=$(=Max(MonthID))"}, YearID={$(=Max(YearID))}

Not applicable
Author

Yes you Right!

It came up a large number, but I will validate that is correct.

Thank you very much