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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
davidqsuires
Frequent Visitor

DAX Formula Comparison

After recently building out our first SSAS Tabular data model, we ended up with 2 measures/methods to get my company's Fiscal Year to Date Sales. I did not build the initial formulas and i'm new to DAX so I could use a little help. 

 

One method is performing much better when test drilling through our cube in Excel. I am trying to get the slower method to work as fast, as the faster method. If that makes sense. 

 

The slow method requires picking a date out of our date table, then pulling in this measure. It works but it's slow. Is there anything obvious we could tweak on this to make it work faster?

 

 

Fisc YTD Sales :=
IF (
    HASONEVALUE ( 'Invoice Date'[Fiscal Year] ) && MAX ( 'Invoice Date'[Date] ),
    CALCULATE (
        [Sales],
        ALL ( 'Invoice Date' ),
        FILTER (
            ALL ( 'Invoice Date' ),
            'Invoice Date'[Fiscal Year] = VALUES ( 'Invoice Date'[Fiscal Year] )
                && 'Invoice Date'[Date] <= MAX ( 'Invoice Date'[Date] )
        )
    ),
    BLANK ()

 

The faster method requires using a "Relative Fiscal Year Offset" field in our date table. 0 would be the current fiscal year. 

We then just drag in our "Sales" measure which is simply: Sales:=CALCULATE(SUM([LineAmount])). We use the Sales measure for any dynamic date range of sales but the Fiscal YTD Sales measure is always the current YTD sales for the date selected. 


Thanks for any help ! 

 

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@davidqsuires

 

In DAX, to calculate YTD for fiscal years, you can directly use TOTALYTD(), and specify a year_end_date argument in this function. For example:

 

=TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey], ALL(‘DateTime’), “6/30”)

It should perform much faster than your above formula. For more details, please see: TOTALYTD()

 

 

Regards,

Simon Hou

View solution in original post

1 REPLY 1
v-sihou-msft
Microsoft Employee
Microsoft Employee

@davidqsuires

 

In DAX, to calculate YTD for fiscal years, you can directly use TOTALYTD(), and specify a year_end_date argument in this function. For example:

 

=TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey], ALL(‘DateTime’), “6/30”)

It should perform much faster than your above formula. For more details, please see: TOTALYTD()

 

 

Regards,

Simon Hou

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.