Forum Discussion

JCdata1992's avatar
JCdata1992
Regular Visitor
2 years ago

How to avoid multiple measures for different categories

 

I have a database that analyzes different categories of costs in several years. I want to calculate the percentage change of each with respect to the previous year. The problem is that I want to avoid creating many measures for each of the categories. For example, Category "transportation costs" for the year 2015, and so on for the year 2016 and then use that measure and measure the percentage change between them. The question is: Is there a way to create more generic measurements? My table is divided into "categories", "period" (I'm interested in only the year) and value (USD). I have a total for each cost category in each year.









 

2 Replies

  • mlsx4's avatar
    mlsx4
    Memorable Member

    Hi JCdata1992 

     

    Take a look at functions such as PARALLELPERIOD or DATEADD.

     

    Then you will only need to create two measures. For example, imagine you want to compute sales: one for the total sales and another for the previous year CALCULATE(total sales, PARALLELPERIOD( [Dates],-1,YEAR). 

    In this way, when you apply context, you will obtain what you need

    • JCdata1992's avatar
      JCdata1992
      Regular Visitor

      Thanks for your answer. However, i.e, I want to sum and work with the total cost by each category (I have 9 cost category) by year (I have 9 years; 2015-2023). The idea is to work with those totals and then with the results, calculate the variation year by year and represents the % contribution of its amount respect the total amount in the same year. I want to know if there is a simple way instead of creating a variety of measures of each one