I can't seem to get the correct result from the LinRegSlope function in Mondrian MDX. I have a cube with three dimensions:
and one of my measures is the Rain in mm.
For a fixed month (July) I want to calculate the slope of the regression line, with on the y-axis the average rainfall over the stations and on the x-axis the years:
![]()
As you can see, that slope should be -0.03.
To do the same in Saiku, I created the following MDX query:
WITH
SET [SelStations] as {[Station].[Station].Members}
SET [SelYears] as {[Year].[Year].Members}
MEMBER [Measures].[AvgMeasure] as Avg({[SelStations]},[Measures].[Rain (mm)])
MEMBER [Measures].[Slope] as LinRegSlope([SelYears],[Measures].[AvgMeasure])
SELECT
{[Measures].[Slope],[Measures].[AvgMeasure]} ON 0,
{[SelYears]} on 1
FROM
[StationData]
WHERE
{[Month].[Month].[7]}
But Saiku reports -3.72 as the regression slope.
I must be doing something wrong here, but I don't really understand what. Is there anyone who knows how to correctly use the LinRegSlope function?
- Station
- Year
- Month
and one of my measures is the Rain in mm.
For a fixed month (July) I want to calculate the slope of the regression line, with on the y-axis the average rainfall over the stations and on the x-axis the years:

As you can see, that slope should be -0.03.
To do the same in Saiku, I created the following MDX query:
WITH
SET [SelStations] as {[Station].[Station].Members}
SET [SelYears] as {[Year].[Year].Members}
MEMBER [Measures].[AvgMeasure] as Avg({[SelStations]},[Measures].[Rain (mm)])
MEMBER [Measures].[Slope] as LinRegSlope([SelYears],[Measures].[AvgMeasure])
SELECT
{[Measures].[Slope],[Measures].[AvgMeasure]} ON 0,
{[SelYears]} on 1
FROM
[StationData]
WHERE
{[Month].[Month].[7]}
But Saiku reports -3.72 as the regression slope.
I must be doing something wrong here, but I don't really understand what. Is there anyone who knows how to correctly use the LinRegSlope function?