Forum Discussion

lmondavi's avatar
lmondavi
Frequent Visitor
8 years ago

Year over Year with tricky dates

Hi, I have data with fiscal quarter (text field) as the lowest aggregation level on each transaction. I have a calendar table that includes a related Start Date and End Date for each fiscal quarter, as well as the related fiscal half, and fiscal year. I am stuck on how to create the measures for a YoY calculation. I want to show the total revenue value in a table or chart for Current Period, Prior Period, and YoY %. All of the example I have seen seem to need an actual date to use DATEDIFF, DATEADD or similar. How can I define Prior Period to align properly to each Current Period given this data? Basic example tables attached. thank you for any assistance!

 

DataTable  CalendarTable    
RevenuePeriod PeriodStart DateEnd DateFYFH
150002017-Q1 2017-Q111/1/20161/31/201720172017-H1
14002017-Q1 2017-Q22/1/20174/30/201720172017-H1
200002017-Q2 2017-Q35/1/20177/31/201720172017-H2
23002017-Q2 2017-Q48/1/201710/31/201720172017-H2
180002017-Q3 2018-Q111/1/20171/31/201820182018-H1
17002017-Q3 2018-Q22/1/20184/30/201820182018-H1
160002017-Q4 2018-Q35/1/20187/31/201820182018-H2
16552017-Q4 2018-Q48/1/201810/31/201820182018-H2
140002018-Q1      
18002018-Q1      
250002018-Q2      
21102018-Q2      
170002018-Q3      
16002018-Q3      
160002018-Q4      
21002018-Q4      

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    lmondavi try something like this. Just try writing the formula instead of copy pasting as  I might have missed out quotes.

     

     

    CALCULATE(SUM(DataTable[Revenue]), FILTER(CalendarTable, CalendarTable[Start Date] >= DATEADD(CalendarTable[Start Date],-1,Year) && CalendarTable[End Date] < DATEADD(CalendarTable[End Date],-1,Year)))

    • lmondavi's avatar
      lmondavi
      Frequent Visitor

      Unfortunately that didn't work, thanks for the reply though

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi lmondavi

    After testing with any DATETIME function, like DATEDIFF, DATEADD or similar, it is not possible to get results as you expected.

    Here is a workaround.

    Assume "Prior Period" here refers to the same quarter of the last year.

    1.create relationship between two tables

    2. create measures columns in DataTable

    Measure

    Current Period = CALCULATE(SUM('DataTable'[Revenue]),ALLEXCEPT('DataTable','DataTable'[Period]))

    Columns

    date-start = RELATED(CalendarTable[Start Date])
    
    Prior Period =
    CALCULATE (
        SUM ( 'DataTable'[Revenue] ),
        FILTER (
            ALL ( 'DataTable' ),
            MONTH ( [date-start] ) = MONTH ( EARLIER ( 'DataTable'[date-start] ) )
                && YEAR ( [date-start] )
                    = YEAR ( EARLIER ( 'DataTable'[date-start] ) ) - 1
        )
    )

     

    Please let me know how to calculate YoY %.

     

    Best Regards

    Maggie

    • lmondavi's avatar
      lmondavi
      Frequent Visitor

      Thanks, but I don't think this is flexible enough. I need to bring in other filters, but the 'current period' does not repond to those filters. Also, with this solution I would have to create so many new measures and columns for every value that I need to do a year over year comparison for. thank you for taking time to answer, I do appreciate it