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: 
qlikviewuser20
Contributor III
Contributor III

YearToDate

Hi,

thank you for your post.

I did use the YTD function but it doesn't work for me.

I have a simple table with :

dateAmount
2015/12/3143315257
2020/06/3010087819
2020/07/31-1269887020
2020/08/307597395

i did use this expression :

sum({<YEAR={$(=($(vCurrentYear)))}, DATE={"<=$(=Max(DATE))"}> }Amount)

to calculate the amount of the current month till the amount of january of the current year but it doesn't work

I also tried this expression:

Sum({< DATE={">=$(=Num(YearStart(Max(DATE))))<=$(=(Max(DATE)))"}>} Amount)

But same thing it just calculate the amount of the current month and i don't know how to fix that :s


Any help ?

Thank you very much !

19 Replies
qlikviewuser20
Contributor III
Contributor III
Author

Can you just explain me, please, the expression proposed?

sunny_talwar

I am doing accumulation over Year_Month but since this needed to be reset every year, I had to use Year as a dimension.

So, this is doing a accumulation

RangeSum(Above(Sum({< DATE, MONTH, YEAR_MONTH>} Amount), 0, RowNo()))

and this is to make sure that it resets every year

Aggr( ... , YEAR, (YEAR_MONTH, (NUMERIC)))

qlikviewuser20
Contributor III
Contributor III
Author

Thank you very much.

Last question : if i have to display other dimension on my table did i have to include those dimension in the aggr function ?

sunny_talwar

In that case, I would suggest you to look at thisThe As-Of Table

AsOfTable will remove the need to use Aggr() and will work beautifully with multi-dimensions

qlikviewuser20
Contributor III
Contributor III
Author

So there is no other solution ?

Because i should not modify the script or add other tables :s

sunny_talwar

There might be, but difficult to say without looking at it and also knowing the expected output

qlikviewuser20
Contributor III
Contributor III
Author

The idea is exactly the same calculate the amount between the current year month and january of the current year and agrgegate by multiple dimensions just like that :

 

123456 Amount
DIM1ADIM_ADIM_3.1DIM_4.1DIM_5.12016-12145575
DIM_5.22016-1294005055
DIM5.32016-06304435
DIM5.42016-07104423048
BDIM_BDIM_3.2DIM_4.2DIM_5.12016-1218607915
DIM_5.22016-121460447
DIM5.32016-0617291174
DIM5.42016-0753658
DIM5.62016-07917048
DIM5.72016-072572000
sunny_talwar

Expected output?

qlikviewuser20
Contributor III
Contributor III
Author

that was the expected output. Actually i have to calculate the sum of amount per date and per many other dimension. So for the dimension A and the sub_dimensions i have to calculate the amount of the current month until january of the current year.

qlikviewuser20
Contributor III
Contributor III
Author

i attached in excel file the output expected.