Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
grajmca_sgp123
Creator
Creator

how to calculate current sales status(Growth or drop) compared with previous year sales

hi,

I have a requirement to to calculate "Status" fields based on CurYear vs PreYeas sales values.

Here below is the scenario,can you please provide your suggestion on it.

compare with previous sales values with current year sales values,if current year sales values are higher than previous year sales values, show status as growth else show it as drop.

 

dimAdimByearsalesStatus
A1B12019100 
A1B12020200growth
A3B320195000 
A3B320202000drop
A4B420191000 
A4B4202070000growth

 

2 Replies
grajmca_sgp123
Creator
Creator
Author

I have done it by using set analysis,but I want to calculate this Status field in script level.

using set analysis:

if( Sum({$<Year = {"$(=$(vCurrentYear))"},MonthNum = {"<$(=$(vCurrentMonth))"}>} [Profit (USD)])
> Sum({$<Year = {"$(=$(vCurrentYear)-1)"},MonthNum = {"<$(=$(vCurrentMonth))"}>} [Profit (USD)]),'Growth','Drop'
)

Taoufiq_Zarra

@grajmca_sgp123  One option in script :

Data:
LOAD * INLINE [
    dimA, dimB, year, sales
    A1, B1, 2019, 100
    A1, B1, 2020, 200
    A3, B3, 2019, 5000
    A3, B3, 2020, 2000
    A4, B4, 2019, 1000
    A4, B4, 2020, 70000
];

output:

load *,if(dimA=peek(dimA) and dimA=peek(dimA),if(peek(sales)<sales,'growth','drop')) as Status resident Data order by dimA,dimB,year;

drop table Data;

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉