Forum Discussion

mbegg's avatar
mbegg
Advocate II
9 years ago
Solved

YTD line chart

Hi,     I have monthly data with 30 June year end back to July 2014 (so 3 fiscal years worth). I want a YTD line chart with each fiscal year a separate colour line.    I have created a quick meas...
  • GilbertQ's avatar
    GilbertQ
    9 years ago

    Hi mbegg

     

    I would suggest creating a YTD measure where you use a Date Table also. This will ensure that you can then get the right values for your measures.

     

    YTD = TOTALYTD(sum('TableName'[ColumnName]),'Date'[Calendar Date],ALL('Date'),"06/30")

    And here is a blog post around why you need a date table and how to create one.

     

    Do you need a Date Dimension

  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi mbegg,

     

    As GilbertQ mentioned above, an individual Calendar table is needed in this case. You can use CALENDARAUTO function to create it, and then create a relationship between your fact table and this Date table with the date column.

     

    Date = CALENDARAUTO()

    And the formula below is for the new YTD measure using Date[Date] column.

     

    Value_YTD_Fis = 
    IF(
    	ISFILTERED('Date'[Date]),
    	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy"),
    	TOTALYTD(SUM('Sheet1'[Value]), 'Date'[Date],"30/6")
    )

     

    Here is the modified pbix file for your reference. :smileyhappy:

     

    Regards