Forum Discussion

rajanimaddala's avatar
rajanimaddala
Icon for Helper II rankHelper II
6 years ago

Sameperiodlastyear

Hi mates
I have dataset of sales for 2 years. FY starts from Aug to Jul.
I have a slicer for FY.
I am trying to get Sales from YTD(Aug to Dec current FY) but data set has future dates which is fine. And also need to get last year sales for the sameperiod(2018 Aug to Dec current date).
I have created measure to get current YTD revenue as
Sales YTD = SUMX(Filter(table, salesdate <= today()), salesvalue)

How do I get last year sales value(DAX expression)?

Regards

2 Replies

  • Hi rajanimaddala ,

    Your YTD looks a little weird. Do you want a measure similar to the following:

     

    Sales YTD =
    VAR _lastdate =
        DATE ( YEAR ( NOW () ) - 1, MONTH ( NOW () ), DAY ( NOW () - 1 ) )
    RETURN
        SUMX ( FILTER ( table, salesdate <= _lastdate ), salesvalue )

     

    If it doesn't meet your requirement, kindly share your sample data and expected result if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

    Best Regards,

    Community Support Team _ Joey
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Hi rajanimaddala ,

     

    In order to calculate last year sales you can use any measure out of below 4 mentioned:

    1. Last Year Sales  = CALCULATE(SUM([Total Sales]),DATEADD([Date]),-1,YEAR))

    2. Last Year Sales  = CALCULATE(SUM([Total Sales]),PREVIOUSYEAR([Date]))

    3. Last Year Sales  = CALCULATE(SUM([Total Sales]),PARALLELPERIOD([Date],-1,YEAR))

    4. Last Year Sales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(‘Calendar’ [Date]))

     

    Please give Thumps up for Support and accept this as a solution if it helps you!