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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

YTD Computation

Hi All!

Just gonna ask a question regarding the computation of YTD.

We all know that getting the YTD we'll be using a set analysis that limits the year,month,quarter..

Sum({<Year={$(=Max(Year))},MonthNum = {"<=$(=Max(MonthNum))"}, Month=, Quarter=>} [fieldname])

The Problem:

Since I'll be multiplying this formula to a specific field, let us say [cost per month], which gives me the

formula now to:

(sum(amount) - Sum({<Year={$(=Max(Year))},MonthNum = {"<=$(=Max(MonthNum))"}, Month=, Quarter=>} [fieldname])) * [cost per month]


Now, my [cost per month] is different per Month. let's say i tick the month of March.. the formula gives me the YTD (Jan,Feb and March totals) but since I tick March, it will only get the [cost per month] of March. How can I get the [cost per month] of Jan and Feb?


What approach should I do?


Thanks in advance,

Donna

9 Replies
tresesco
MVP
MVP

Try Like:

Sum({<Year={$(=Max(Year))},MonthNum = {"<=$(=Max(MonthNum))"}, Month=, Quarter=>} [fieldname] * [cost per month] )

I.e. take the [cost per month] part inside of sum().

its_anandrjs
Champion III
Champion III

Write like below and yes take Cost per month in sum part

Sum({<Year={"$(=Max(Year))"},MonthNum = {"<=$(=Max(MonthNum))"}, Month=, Quarter=>} [fieldname] * [cost per month])

Not applicable
Author

tresesco and Anand Chauhan

Unfortunately this doesn't work as this will alter my formula.

my original formula is getting the (amount-formula above)*[costpermonth]/1000.

will update the details on the post.

Thanks!

Not applicable
Author

bump

Not applicable
Author

bump

tresesco
MVP
MVP

Could you post a sample app explaining expected output there?

Not applicable
Author

Hi,

I can only send a visual on excel, below is an example for Jan-Feb

MonthAmt_FinalVolumeTotal Cost of SalesAmt_Final - Volume*Total Cost(Amt_Final - Volume*Total Cost) / Volume
Jan          1,341,542,456       30,325,29042.7644,833,055.601.006122705
Feb          1,379,869,091       32,547,09141.8318,424,274.47

Since in qlikview we sum up the totals:

Qlikview

Month (YTD)

Amt_Final

Volume

Total Cost of Sales

Amt_Final - Volume*SUM(Total Cost of Sales)
Jan-Feb          2,721,411,547       62,782,381?
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Assuming month is the only dimension in the table, I suggest

=Sum(Aggr((Sum(amount) - Sum({<Year={$(=Max(Year))},MonthNum = {"<=$(=Max(MonthNum))"}, Month=, Quarter=>} [fieldname])) * [cost per month], Month))

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rohit214
Creator III
Creator III

Hi

sum({<Year={$(=(max(Year))},Monthnum={"<=$(=max(MonthNum))"},Month=,Quater=>}[fieldname])

*

sum({<Year={$(max(Year))},MonthNum={"<=$(=Max(Monthnum))"},Month=,Quater=>}[cost per month])

Thanks

Rohit