Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Measure for YTD and YTG

Hi,

 

I'm analyzing history, actuals and forecast, All on the same column.

I created a calendar table to get the evolution year on year. However, I'm having trouble to get the YTD (%) showing the evolution of actuals and the evolution of the YTG (forecast). The measures that I have tried shown an error or gave me a wrong number. I can't identify what I'm doing wrong.  Can someone provide some advice of how to do this. Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use following measure to calculate YTD based on calendar date:

YTD =
VAR currDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Raw Data'[Sales] ),
        FILTER (
            ALLSELECTED ( 'Raw data' ),
            'Raw data'[Date] <= currDate
                && YEAR ( 'Raw data'[Date] ) = YEAR ( CurrDate )
        )
    )

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @Anonymous,

 

Please share some sample data and dax formula that we can test and coding formula on it.

How to Get Your Question Answered Quickly

 

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Thank you @Anonymous!

 

Here a sample of the data:

 

RegionYearMonthSalesDayDate
Africa2016115.05511/1/2016
Africa2016215.41812/1/2016
Africa2016317.74813/1/2016
Africa2016418.08414/1/2016
Africa2016517.52415/1/2016
Africa2016617.50416/1/2016
Africa2016718.50817/1/2016
Africa2016819.61418/1/2016
Africa2016919.15619/1/2016
Africa20161018.872110/1/2016
Africa20161117.275111/1/2016
Africa20161218.621112/1/2016
Africa2017115.80811/1/2017
Africa2017214.95512/1/2017
Africa2017317.39313/1/2017
Africa2017417.54114/1/2017
Africa2017518.415/1/2017
Africa2017617.67916/1/2017
Africa2017718.13817/1/2017
Africa2017819.61418/1/2017
Africa2017919.53919/1/2017
Africa20171018.683110/1/2017
Africa20171117.103111/1/2017
Africa20171218.434112/1/2017
Africa2018115.33411/1/2018
Africa2018214.80612/1/2018
Africa2018317.91413/1/2018
Africa2018417.71714/1/2018
Africa2018519.13615/1/2018
Africa2018618.2116/1/2018
Africa2018721.33317/1/2018
Africa2018822.09818/1/2018
Africa2018920.49219/1/2018
Africa20181018.692110/1/2018
Africa20181118.452111/1/2018
Africa20181219.2112/1/2018
Africa2019116.41211/1/2019
Africa2019216.11312/1/2019
Africa2019318.66613/1/2019
Africa2019418.42814/1/2019
Africa2019518.23315/1/2019
Africa2019618.46316/1/2019
Africa2019721.87917/1/2019
Africa2019823.2881

8/1/2019

 

I'm trying to use the quick measurment 'Year to date Total' and I already created the date hierarchy on my calendar table. However, it keeps showing an error:

 

Passengers YTD =
IF(
 ISFILTERED('Date'[Date]),
 ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
 TOTALYTD(SUM('Raw Data'[Sales]), 'Date'[Date].[Date])
)

Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use following measure to calculate YTD based on calendar date:

YTD =
VAR currDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Raw Data'[Sales] ),
        FILTER (
            ALLSELECTED ( 'Raw data' ),
            'Raw data'[Date] <= currDate
                && YEAR ( 'Raw data'[Date] ) = YEAR ( CurrDate )
        )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.