7 Replies Latest reply on Apr 30, 2013 12:26 PM by Devarsh Shah

# Compare a given metric for two time frames

I have a metric which I would like to compare dynamically based on the two different date ranges available for selection. So for example, I would like the user to be able to select Date Range selector A and B and the metric X calculated as SUM(X) for Date Range A - SUM(X) for Date Range B. Is this possible? If yes, how do I implement it?

• ###### 1. Re: Compare a given metric for two time frames

Hi Devarsh,

One way to do this would be to create two date parameters. Then, create two calculated fields one for each date range, similar to the following:

Date Range A:

if [Order Date]<=[date range a] then Sales end

Date Range B:

if [Order Date]<=[date range b] then Sales end

Then, create a third calculation to find the difference:

sum([Date Range A])-sum([Date Range B])

Hope this helps!

-Tracy

• ###### 2. Re: Compare a given metric for two time frames

Hi Tracy,

Thanks for the reply. I do not want to calculate the difference in date but the difference in say, Cost, based on the two different dates that I have selected. So lets say the cost for the time frame A is 100 and time frame B is 70 then I would like to be able to calculate the difference in cost which is 30.

Devarsh

• ###### 3. Re: Compare a given metric for two time frames

Hi Devarsh,

In the top two calculations it returns the sum of Sales for each selected Date Range--perhaps I named them inappropriately! Then, the third calculation is the difference of these two sum of Sales.

-Tracy

• ###### 4. Re: Compare a given metric for two time frames

Ok yes that makes sense. However the date parameter doesn't allow me to select a date range - it only allows selection of a specific date.

• ###### 5. Re: Compare a given metric for two time frames

Hi Tracy,

Is there a way to have the date parameter to show as the date range slider so that I can include a range of dates and not just select a single date?

Thanks,

Devarsh

• ###### 6. Re: Compare a given metric for two time frames

Hi Devarsh,

You could make 4 date parameters or make the calculations comparable to today(). Then, adjust the calculations to address multiple parameters:

if [Order Date]<=[date range a] or [Order Date]>=[date range 1a] then Sales end

This is definitely not ideal. Might be a good one for the Ideas section.

-Tracy

1 of 1 people found this helpful
• ###### 7. Re: Compare a given metric for two time frames

Thanks for your help Tracy.