Forum Discussion

1241pm's avatar
1241pm
Frequent Visitor
8 years ago
Solved

two tables with 2 dates, create relative month

Hi, I have two tables names Projection 1 and Projection 2.  The tables both have dates and sales values. Projection 1's dates range from September 2016 - December 2018 while Projection 2 goes from S...
  • Seward12533's avatar
    Seward12533
    8 years ago

    Ok I misunderstood so you want to plot Relative Months along with X Axis and then Compare Sept 17 data to Sept 18.  Assuming you have a Date field in your data you can add a column and use DATEDIFF.

     

    You could add a shifted date column to calcuate the date 1 year earlier in Shifted Date = DATE(YEAR([date])-1,Month([date],DAY([date])) and then bridge that to your date table vs Date and then plot as Anonymous suggested. 

     

    Or Alternatively you could implement your Relative Date method with somethign like this. 

     

    First Write a Measure to calculat the first Month for each Table

    • Proj1 Start Month = CALCULATE(MONTH(MIN(proj1[Date])),ALL(Proj1))
    • Proj2 Start Month = CALCULATE(MONTH(MIN(proj2[Date])),ALL(Proj2))

    Then add a column to each for Relative Month 

    • Relative Month = DATEDIFF([Proj1 Start Month],[Date],month)
    • Similar column in Proj2 using [Proj2 Start Month] measure

    Then you need a bridge table for the Relative Months.