Forum Discussion

jfern78's avatar
jfern78
Frequent Visitor
2 years ago

Calculate % difference between two years

I would like to work out % difference between 2 years for a set of values and having some trouble doing so.

 

First of all, let’s say I have the following sample of data

 

Year

Active/Inactive Sale

Deparment

2020

ActiveMontevideo
2019ActiveMontevideo
2020InactiveSalto
2020ActivePaysandu
2019InactiveSalto
2019ActiveMontevideo
2020InactiveCanelones
2019ActiveCanelones

 

The column Year is a integer number not a date value.
I need to calculate 2023 vs 2022, vs 2021 vs 2020. 

 

 

 Montevideo  Salto  
Active/Inactive Sale20192020% change20192020% change
Active23%19%-4%22%16%-6%
Inactive22%19%-3%13%21%8%
Mary24%22%-2%12%26%14%

 

I used this measure to calculate the chosen selection of the slicer

Spoiler
Measure = 
 var _sliceryear = CONCATENATEX(DISTINCT('Cartera Total'[yearslicer]),[yearslicer])
 var _converts = CONVERT(_sliceryear,INTEGER)
var _lastyear = CALCULATE(COUNTA('Cartera Total'[system_no]),FILTER(ALL('Cartera Total'),'Cartera Total'[FY Año Alta]=_converts-1 && 'Total Sales'[Active/Inactive]="Inactive"))
return _lastyear

any suggest?

 

4 Replies

    • jfern78's avatar
      jfern78
      Frequent Visitor

      Thanks, i will see it. i'm figuring out how to do it.

    • jfern78's avatar
      jfern78
      Frequent Visitor

      i made a column with correct FY Year/date, but when i try to calculate last year sales return me blank.

       

      Total Sales Last Year = CALCULATE([Total Cartera Activa],dateadd('Cartera Total'[Fiscal Date],-1,Year))

       

      • some_bih's avatar
        some_bih
        Community Champion

        Hi jfern78 use Date / Calendart table to "leverage" proper usage of Power BI time intelligence functions like YTD, MTD... do not put fact table year column in visual.