Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
udemiroz
Contributor
Contributor

Compare selected years sales with previous years sales

Hi,

I have a table like Salesdate,product_id,Total. I added a KPI and want to show Selected Years Sales and and previous years sales.

I added a field tom my sheet to select the year.(salesdate.year).

What should be in expression of the kpi data.

Regards.

6 Replies
Anil_Babu_Samineni

Create Field like

Load Salesdate,

         product_id,

         Total,

         Year(Salesdate) as salesdate.year

From Table;

Then, Measure looks like this?

='Current Year ' & Sum({<salesdate.year = {'$(=Max(salesdate.year))'}>} Total) & Chr(10) & 'Previous Year ' & Sum({<salesdate.year = {'$(=Max(salesdate.year-1))'}>} Total)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
udemiroz
Contributor
Contributor
Author

I have created a filed in Sales table like year which is the year of the sales_date.

I have 2 KPI's now. both have different measurment. but the results are the same.

New Bitmap Image.bmp

udemiroz
Contributor
Contributor
Author

Results are the same.

New Bitmap Image (2).bmp

ElizaF
Creator II
Creator II

The solution that provided by Anil is correct, with the observation that the correct expression is:

='Current Year ' & Sum({<salesdate.year = {'$(=Max(salesdate.year))'}>} Total) & Chr(10) & 'Previous Year ' & Sum({<salesdate.year = {'$(=Max(salesdate.year)-1)'}>} Total)


udemiroz
Contributor
Contributor
Author

Still the same result. I'm selecting the year from the field I added to my sheet which is Saledate.year. Is there something wrong with it? Logically this expression should work but it's n ot

fabianaiglesias
Creator
Creator

Hi,

Create these variables:

vCurrentYear = Max(Year)

vPreviousYear = Max(Year-1)

vCurrentTotal = Sum({<Year={$(vCurrentYear)}>}Total)

vPreviousTotal = Sum({<Year={$(vPreviousYear)}>}Total)

I hope this solve your problem