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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MB2
Frequent Visitor

DatesYTD Equivalent to Use with Direct Query

I am looking for an expression that can substitute for the DatesYTD function in DAX. The DatesYTD function is not compatible with DirectQuery as per here, but I need to use DirectQuery as I am dealing with 50M records and I don't want to use Tabular for this instance. Also, this report is also being saved to Power BI Report Server.

 

I am not completely convinced the issue is with just DirectQuery (as DatesYTD with DirectQuery works fine in Desktop), the issue appears when I open the report via Power BI Report Server: "Function 'DATESYTD' is not supported in DirectQuery mode.
Please try again later or contact support. If you contact support, please provide these details."

 

Here is my DAX formula using the DatesYTD:

**bleep**. Amount (by Year) = CALCULATE(SUM('Product'[Amount]), DATESYTD(Calender[SnapshotDate]), ALLEXCEPT('Product','Product'[ResultsDescription],'Product'[Member],Branches[Division],Branches[Branch]))

I am using the DAX measure to compare cummulative growth by week, with a new line for each year.

 

Thanks

1 ACCEPTED SOLUTION
MB2
Frequent Visitor

Hi DAX0110,

 

I am glad I asked, because I would not have come up with this. You are a genius! The only change that I had to make was to add MAX and correct my poor spelling of 'Calendar'

 

Cummulative Amount (by Year) =
VAR joinDate = MAX( 'Calendar'[SnapshotDate] )
VAR joinYear = YEAR(MAX('Calendar'[SnapshotDate]) )
RETURN CALCULATE(
    SUM('Product'[Amount])
    , FILTER(
        ALL( Calendar )
        , YEAR(Calendar[SnapshotDate]) = joinYear
        && Calendar[SnapshotDate] <= joinDate
        )
    , ALLEXCEPT( 'Product'
        ,'Product'[ResultsDescription]
        ,'Product'[Member]
        ,Branches[Division]
        ,Branches[Branch]
        )
    )

View solution in original post

3 REPLIES 3
DAX0110
Resolver V
Resolver V

Hi @MB2, please try the following to see if it works for you as a replacement for DATESYTD in DirectQuery mode:

 

**bleep**. Amount (by Year) =
VAR joinDate = MAX( 'Product'[JoinDate] )
VAR joinYear = YEAR( joinDate )
RETURN CALCULATE(
    SUM('Product'[Amount])
    , FILTER(
        ALL( Calender )
        , YEAR(Calender[SnapshotDate]) = joinYear
        && Calender[SnapshotDate] <= joinDate
        )
    , ALLEXCEPT( 'Product'
        ,'Product'[ResultsDescription]
        ,'Product'[Member]
        ,Branches[Division]
        ,Branches[Branch]
        )
    )
    

// you'd need to make some mods to this formula: 

//      replace 'Product'[JoinDate] with the actual date column used in the relationship with Calendar

 

MB2
Frequent Visitor

Hi DAX0110,

 

I am glad I asked, because I would not have come up with this. You are a genius! The only change that I had to make was to add MAX and correct my poor spelling of 'Calendar'

 

Cummulative Amount (by Year) =
VAR joinDate = MAX( 'Calendar'[SnapshotDate] )
VAR joinYear = YEAR(MAX('Calendar'[SnapshotDate]) )
RETURN CALCULATE(
    SUM('Product'[Amount])
    , FILTER(
        ALL( Calendar )
        , YEAR(Calendar[SnapshotDate]) = joinYear
        && Calendar[SnapshotDate] <= joinDate
        )
    , ALLEXCEPT( 'Product'
        ,'Product'[ResultsDescription]
        ,'Product'[Member]
        ,Branches[Division]
        ,Branches[Branch]
        )
    )

Greg_Deckler
Super User
Super User

Perhaps you could create a column that is the number of days ago, DATEDIFF and NOW are both supported. Then, you could create your measure by filtering on how many days ago.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.