Forum Discussion

WishAskedSooner's avatar
WishAskedSooner
Continued Contributor
1 year ago
Solved

YTD Chart Not Working Properly

I am playing around in the Adventure Works PBIX. One scenario I am testing is when the dates don't align exactly in the fact table. For example, I edited the fact table and deleted all the rows for B...
  • parry2k's avatar
    1 year ago

    WishAskedSooner try something like this, replace table and column names as per your model

     

    YTD Last Transaction Date = 
    VAR __LastTransactionDate = CALCULATE ( MAX ( Sales[OrderDate] ), ALL () )
    RETURN
    CALCULATE (
        [Sales],
        DATESYTD ( 
            CALCULATETABLE (
                VALUES ( 'Calendar'[Date] ),
                KEEPFILTERS (
                    'Calendar'[Date] <= __LastTransactionDate
                )
            )
        )
    )