Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
marikabi
Creator
Creator

Formula to find the trend in Pivot table

Hello,

on a weekly basis I receive a report with the amount of sold items per each shop.

We have several shops in different countries.

I have a Pivot Table, where I calculated the Sum(SALES) based on the dimensions COUNTRY and DATE.

I would like now to add an expression to calculate the trend (using linest_m ) of the last 3 weeks per each specific country.. would it be possible?  

   

COUNTRYDATESALEStrend last 3 weeks
A4220-10
A41309
A404013.5
A3912-1
A3813-4.5
A3714
A3622
B42233
B41243
B4017-1
B3918-26
B3819-30.5
B3770
B3680
8 Replies
marikabi
Creator
Creator
Author

Hello guys, any idea how to proceed?

Anil_Babu_Samineni

Looks like you have Historical Data? Why you want to use Linest_M ?? Little confused, How you calculated the data?

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
shiveshsingh
Master
Master

what's the logic for last column? have you already calculated it or you need expression for that?

chrismarlow
Specialist II
Specialist II

Marika,

If you just want to replicate what you have you can try (sum(SALES)-above(sum(SALES),2))/2;

317872.png

Regards,

Chris.

marikabi
Creator
Creator
Author

Hello,

yes I have historical data, and every week with data load of new report they are concatenated and stored with old data in a qvd file.

What I want to do is to identify the coefficient of linear regression line (then will be represented with a red/green light) to evaluate the trend of last 3 weeks.

So if we are in week 42, I want to evaluate the trend taking into account weeks 42, 41 and 40 - so for every week and every country, I want to consider that specific week + the previous 2 weeks.

I prepared the table using fake data and excel with the formula Linest(known Y, known X)

Hope this clarify

marikabi
Creator
Creator
Author

Hello Chris,

I think that even if the result is the same, it's not what I'm looking for..

the table was created to simplify my case, in reality I need to consider 10 weeks, so probably it wont work

I used on excel the formula Linest(known Y, known X).

Thank you

marikabi
Creator
Creator
Author

Hello,

I need a formula to identify the coefficient of linear regression line (then will be represented with a red/green light) to evaluate the trend of last 3 weeks.

So if we are in week 42, I want to evaluate the trend taking into account weeks 42, 41 and 40 - so for every week and every country, I want to consider that specific week + the previous 2 weeks.

I prepared the table using fake data and excel with the formula Linest(known Y, known X)

chrismarlow
Specialist II
Specialist II

Marika,

Yes, I see what you mean.

I tried to use above to feed into LINEST_M - there are a number of other threads that allude to issues with this suggesting using AGGR/TOTAL to get around this. It beat me.

However I think there is a workaround using correlation coefficient and standard deviation to calculate the slope (Simple linear regression - Wikipedia) which do have range function equivalents, so this could be collapsed down, but right most columns below are given by;

=rangecorrel(above(only(DATE),0,$(varRange)),above(sum(SALES),0,$(varRange)))

=RangeStdev(above(sum(SALES),0,$(varRange)))

=RangeStdev(above(only(DATE),0,$(varRange)))

CorrelDS*SalesSTDEV/DateSTDEV

317872_1.png

Also attaching the QVW (although have personal edition … so not sure if you will be able to open).

Hope this helps.

Cheers,

Chris.