Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
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

Anonymous
Not applicable
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)


Anonymous
Not applicable
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

Anonymous
Not applicable
Author

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