# Power BI & DAX: How to Compare Timeseries with Different Start Dates

Let’s say you want to compare time series of two product launches that are six months apart. Plotting data chronologically will not be very user friendly. The best way to do it is to plot them based on number of days from the launch date. This way we can easily see which product grew to \$1m in revenue faster than the other one. Similarly, as we analyze COVID data, we need to be able to compare multiple countries together even though some countries got their first cases much earlier than others.

If this chart looks interesting to you and you would like to learn how to make it, please see the video below:

This is the DAX formula for the calculation:

Normalized Deaths per 1M =

var dateReached = CALCULATE(MIN(‘Cases'[Date]),

‘Cases'[Daily Value]>=30,

KEEPFILTERS(‘Cases'[Metric] = “Confirmed”)

)

var MaxDate = CALCULATE(max(‘Cases'[Date]),

KEEPFILTERS(‘Cases'[Metric] = “Confirmed”)

)

var dayNo = SELECTEDVALUE(‘Days from 30 cases'[Day])

return CALCULATE([Deaths per 1M],

FILTER(ALL(‘Date’),

‘Date'[Date] = dateReached+dayNo &&

dateReached+dayNo<=MaxDate)

)

## One thought on “Power BI & DAX: How to Compare Timeseries with Different Start Dates”

1. Abhinav says:

Hi,

Thank you very much for posting this great video. I have tried to reimplement what you have done by building a line chart to study vaccination performance in different age groups.

I have found issues with linking Date to Days while plotting. I have tried to follow the same steps as you explained in the video. Like building a ‘Days’ table with 1000 lines, a ‘Date’ table, ‘Normalized Doses’ metric using your above DAX script, and main doses information in ‘Comparison’ table.

But, days in the X axis are not getting restricted ( it is displaying all the way till 1000 days inspite of having below condition in the ‘Normalized Doses’ script)

FILTER (All(‘Date’),

‘Date'[Days]= minDate+daysnum &&

minDate+daysnum=10,

KEEPFILTERS(‘Comparison'[Doses_Dose_Number] = “First Dose”)

)

var maxDate = CALCULATE(MAX(‘Comparison'[Doses_Data_as_of]),

KEEPFILTERS(‘Comparison'[Doses_Dose_Number] = “First Dose”)

)

var daysnum = selectedvalue(‘Days Series'[Days])

return CALCULATE([Running total in Doses_Data_as_of],

FILTER (All(‘Date’),

‘Date'[Days]= minDate+daysnum &&

minDate+daysnum

Thank you,
Abhinav