Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
agustapia
Contributor III
Contributor III

Last year set analysis with max year

Hi all,

I've been dealing with this problem for a while and I'd like you to take a look:

My data set contains Actuals and Budget figures in the same table, separated by a field named TipoMov. Since budget is for the full next year, when I add the next year budget and do a normal set analysis for actuals, last year figures are the same as this year figures:

Sum({$<SalesYear={$(=Max(SalesYear)-1)}, TipoMov = {"Actual"}>} Sales)

(In this moment, Max(SalesYear) = 2019 because of next year budget)

So I tried to add to the Max a set analysis to look only for actuals, but it didn't work:

Sum({$<SalesYear={$(=Max({<TipoMov = {'Actual'}>} SalesYear)-1)}, TipoMov = {"Actual"}>} Sales)

When I execute the prior formula in a textbox, it works as expected, but when included in the set analysis it doesn't work.

Then I tried to get the max year from the data load, and using RangeMin and Max functions, but couldn't  make it work:

Sum({$<SalesYear={$(=RangeMin(Max(SalesYear), $(vMax))-1)}, TipoMov = {"Actual"}>} Sales)

Also when I execute the prior formula in a textbox, it works as expected, but when included in the set analysis it doesn't work.

I have run out of ideas,  so I hope somebody can tell me what I am doing wrong and how to correct it.

I know in 2019 it will be fixed, but I don't want to be facing this same problem next year when I load 2020 budget.

Thanks in advance.

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Are you looking to put Last year info on the same row as the current year? If that is what the goal is... you either need Above()/Below() function or preferably use The As Of Table

View solution in original post

12 Replies
sunny_talwar

So, essentially when you use this in a text box

=Max({<TipoMov = {'Actual'}>} SalesYear) - 1

you see 2017, but when you use this

Sum({$<SalesYear = {$(=Max({<TipoMov = {'Actual'}>} SalesYear)-1)}, TipoMov = {"Actual"}>} Sales)

You still see the Sales for 2018? Is that what the issue is? or do you not see anything at all?

agustapia
Contributor III
Contributor III
Author

I see nulls

sunny_talwar

Are you making selection in another date or time related field which contradicts your set analysis? If you are, then ignore that field in your set analysis like this

Sum({$<SalesYear = {$(=Max({<TipoMov = {'Actual'}>} SalesYear)-1)}, TipoMov = {"Actual"}, MonthYear, FiscalYear, QuarterYear>} Sales)
agustapia
Contributor III
Contributor III
Author

No, in fact this particular view is for historical daily sales, then there is no filter selected
sunny_talwar

I see nothing wrong with your expression... would you be able to share a sample so that we can see what might be going on?

agustapia
Contributor III
Contributor III
Author

Since this is classified info I cannot share a quick sample, but i can create a small app with the problem in it so you can take a look at it, only problem is I would be able to do it until wednesday, how can I get back to you when it is done?
agustapia
Contributor III
Contributor III
Author

Hi again Sunny,

Attached you can find an app with my issue. Something I couldn't realize with my full app (due to the lenght of the data and the complexity of my formulas) is that the formula is indeed working but the "Date" dimension is preventing data to be displayed.

A workaround I thought of  was to add month/day dimensions, remove date dimension and add set expressions to budget and actuall figures, however that would only work for the latest year...

My last resort is to load budget only to the latest actual sales date, but if anyone ever wants to see future butget regardless of not having sales to compare to, I'd have to add it and -again- last year figures might not work.

Thanks for your support! 

sunny_talwar

Can you point to me as to what exactly is the issue here?

image.png

agustapia
Contributor III
Contributor III
Author

In the first row and last year column, for example, i'd expect to see 11,685, which is the actual value of 31/12/2017, this is last year's value