Forum Discussion

Neyney's avatar
Neyney
Frequent Visitor
1 year ago
Solved

Current Year versus Last Year Same time thi

I need to do a Current Year versus Last Year (based on the max date available this current year) ---- My LY YTD SALES formula seems off . My Current Year calculation (CY) based on the max date availa...
  • rubayatyasmin's avatar
    1 year ago

    Hi, Neyney 

    Ty using Dates between, 

    refer, https://learn.microsoft.com/en-us/dax/datesbetween-function-dax

    use this one below, 

    LY YTD Sales =
    CALCULATE(
        [TotalSales],
        DATESBETWEEN(
            'Sample_YTD_Sales_Data'[Paid Date],
            DATE(YEAR(MAX('Sample_YTD_Sales_Data'[Paid Date])) - 1, 1, 1),
            DATE(YEAR(MAX('Sample_YTD_Sales_Data'[Paid Date])) - 1, MONTH(MAX('Sample_YTD_Sales_Data'[Paid Date])), DAY(MAX('Sample_YTD_Sales_Data'[Paid Date])))
        ),
        'Sample_YTD_Sales_Data'[IsPast] = TRUE()
    )
     

     

    attached the pbix file for you.