Forum Discussion

Desarrollador9J's avatar
Desarrollador9J
Frequent Visitor
4 years ago
Solved

EDATE AND SUMX doesn't work

Hi everybody

 

I am using the following measure to add the result of the calculation of a measure in several non-consecutive months:

 

SUMX(Dates,'Measures'[Measure])

 

This works perfectly. For example, when selecting 3 non-consecutive months ('01-01-2022', '02-01-2022',
05-01-2022) is adding the results given by the measure for each month.

 

But now I need it to show me the same sum, but for the equivalent of the months 1 year ago or 2 years ago.

For example, if I select ('01-01-2022', '02-01-2022','05-01-2022'), I would like you to add the result of the measurement calculated for '01-01-2021', '02-01-2021','05-01-2021'. For that I am using this measure:

 

SUMX(FILTER(Date,Date[Date]=EDATE((Date[Date]),-12)),'Measures'[Measure])

 

The problem with using functions like dateadd or parallelperiod is that they don't work with non-consecutive dates.

I would be very grateful to anyone who could help me.

 

LJ.

  • Desarrollador9J,

     

    Try this measure:

     

    Last Year = 
    CALCULATE ( SUM ( FactTable[Amount] ), SAMEPERIODLASTYEAR ( Dates[Date] ) )

     

    The slicer and table visual use Dates columns:

     

    Data:

     

     

1 Reply

  • Desarrollador9J,

     

    Try this measure:

     

    Last Year = 
    CALCULATE ( SUM ( FactTable[Amount] ), SAMEPERIODLASTYEAR ( Dates[Date] ) )

     

    The slicer and table visual use Dates columns:

     

    Data: