# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
Contributor

## How to built Predictions models for qliksense?

Hi experts,

I have a bar graph  which having Total sales of q1,q2,q,3 how to forcast  for q4 in qliksense. Please throw  some light .i went some links

but i could not make.

Thanking You

Krishna

4 Replies
Highlighted
Valued Contributor

## Re: How to built Predictions models for qliksense?

by having a predictive data in excel (or in any format) or you want to do that on calculated base in Qlik?

Regards

Highlighted Partner

## Re: How to built Predictions models for qliksense?

I suggest you to take a look at linest_m and linest_b functions below:

https://help.qlik.com/en-US/sense/June2018/Subsystems/Hub/Content/ChartFunctions/StatisticalAggregat...

https://help.qlik.com/en-US/sense/June2018/Subsystems/Hub/Content/ChartFunctions/StatisticalAggregat...

with these statistical functions you can do a linear regression.

I hope this helps.

Highlighted MVP & Luminary

## Re: How to built Predictions models for qliksense?

The stock answer is probably that you need to use 'Advanced Analytics' as Qlik call it, which is effectively just a technique to throw the data out to R or Python, have that run a model, and then bring it back.

You would have to have a separate expression for the prediction and the actual, but if you stack the bar that would be fine - and it would also allow you to have separate colours.

Similar could be achieved by showing an average of the previous quarters for Q4.

You would need to ensure that you have a Q4 loaded into the data model (so that the dimension exists).

Your expression for actual would be something like:

sum([Total Sales])

The average would be something like:

if(sum([Total Sales]) = 0, sum(TOTAL [Total Sales]) / count(DISTINCT TOTAL {<[Total Sales]={"<>0"}>}Quarter), null())

This basically says that if there are no sales in the quarter, add up the total for the quarters where there are sales and then divide by the number of quarters where there are not.

This approach depends on the data being in full quarters.  If you have monthly data, and need to report on part way through a quarter (e.g Q3 contains one month actual and two months projection) you would need to do similar to the above but do it on a month basis, with an aggr:

sum(aggr(if(sum([Total Sales]) = 0, sum(TOTAL [Total Sales]) / count(DISTINCT TOTAL {<[Total Sales]={"<>0"}>}Month), null()), Month, Quarter))

You may find this post on calculating run-rates of interest: