Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 28687

Linear Trend line for SSRS report on OLAP MDX

$
0
0

I've been converting an Excel dashboard (Pivot Tables and Charts based on an SSAS cube) into SSRS.  An interesting challenge was to reproduce the Excel Pivot Chart Trend Lines using the Linear Trend/Regression Type.  This is equivalent to the TREND formula in Excel.

Blog posts etc were very thin on this, but the general thrust seemed to be that you have to pre-calculate it in the Dataset and then add it to your SSRS chart as a Line series - SSRS itself doesn't offer any direct support for Linear Regression Lines.

The next challenge was writing the MDX formulas to calculate the values. This post gave me the closest hint, but it's very dry:

http://www.mdxpert.com/Functions/MDXFunction.aspx?f=69

So here's what I ended up with, to calculate the Linear Regression of the Income measure for the filtered set of Years:

Calculated Measure #1: RankYears:
 Rank (  [Time].[Year].CURRENTMEMBER  , NONEMPTY ( [Time].[Year].CURRENTMEMBER.LEVEL.MEMBERS , [Measures].[Income] ) )

Calculated Measure #2: Linear Income
LinRegPoint( [Measures].[RankYears] 
, NONEMPTY ( [Time].[Year].CURRENTMEMBER.LEVEL.MEMBERS ,  [Measures].[Income] )
,  [Measures].[Income]
,  [Measures].[RankYears]   )

Has anyone out there had to do this? Does this solution look reasonable?  It seems to be producing the desired results (i.e. the same as Excel).


Viewing all articles
Browse latest Browse all 28687


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>