Forum Discussion

higherkuo's avatar
higherkuo
Regular Visitor
9 years ago
Solved

SAMEPERIODLASTYEAR() function

Hi All,   I'm just start learning Power BI, but I couldn't get my head around on the SAMEPERIODLASTYEAR() function.   Assume I have a table with two columns date and sale, the date ranges from 1/...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Your formula works fine.  You are just not filtering it correctly.  Meaning you need to filter/select the current period you want to measure.

    Try this:

    1. Create a Total Sales measure: Total Sales =

    Total Sales= SUM(ResellerSales_USD[SalesAmount_USD])

     

    2. Create a Previous Year Total Sales =

    Previous Year Total Sales=CALCULATE([Total Sales], SAMEPERIODLASTYEAR(DateTime[DateKey])

     

    3. (Drag your date field into the worksheet and make it into a slicer (use slicer visualization)

    4. Drag your Total Sales and Previous Total Sales fields into the worksheet as well and make them into a card visualization (It is just easier this way, or you can make it into a table visualization)

     

    5. Now select any month in your date slicer.  Pick 3/1/2017.  You will see that the Total Sales card shows 27 and the Pevious Year Sales card shows 15.  You can even select 3/1, 2/1 and 1/1/2017 and it will show you previous year total Jan-March.

     

    So you can see it is working, you need to be able to filter it to your liking.  Hopefully this helps you get started.  The next steps you will need is to create a measure calculation that incorporates a filter such as TOTALYTD.