2 Replies Latest reply on Jan 12, 2018 5:30 PM by Yuriy Fal

# COVAR and VAR return 0 when using a time dimension in Detail or Label

i need to create a scatterplot and express the slope of the trend line in the title

i use the approach identified in : Covariance, Trend Lines, Correlation Coefficient R and R-Squared

if i pre-aggregate the data, in the native excel file, the following formula returns a valid slope (See "pre-aggregated" worksheet in attached)

WINDOW_COVARP(SUM([Hours]),SUM([Tics]))/WINDOW_VARP(SUM([Hours]))

BUT only if i do not include the Month dimension on the Mark card (detail or label).

if i do, slope expresses as "None" and the COVAR and VAR return as 0.

my work-around is to duplicate this as a dual axis, and use the second axis for Month labels.

if i do not pre-aggregate the data and simply use the raw, tableau requires the Month dimension to appropriately segment the data (See "from raw" worksheet in attached).

and i get the result of COVAR and VAR = 0 and slope = "None"

is this a user-error?

• ###### 1. Re: COVAR and VAR return 0 when using a time dimension in Detail or Label

Pinging Jonathan Drummey and Jim Wahl, in case they have time to take a quick look (they both helped/posted in the original link).  I hope this helps - I am not very familiar with these functions, but will try to learn more if I can!

• ###### 2. Re: COVAR and VAR return 0 when using a time dimension in Detail or Label

Hi William,

It looks like a simple Blend would work.

For that you'd like to have the Months pill

from Primary on a view (and Compute along it).

Besides, i've set Relationships back to Automatic

and use a duplicate of the [Date] from Secondary

(renamed to the [Period] for an auto match) to blend on.