0
votes

I have the following table:

Year test is the list of previous year:

=SUMX(Datasrc;Datasrc[Year]-1)

How do I get something similar for "Calculated field 1"? In other words, I want to get the previous "Price/kg" so it match column C, "Year test".

I have tried with the formula from Find rows relative to current row's value in excel (DAX):

=SUMX(
        FILTER(Datasrc; EARLIER([Year]) = [Year] + 1 );
        Datasrc[C_Total Asset Per Share]
)

But only get: "Calculation error in measure 'Datasrc'[Calculated field 2]: EARLIER/EARLIEST refers to an earlier row context which doesn't exist."

The column A is [Year]

1
Sorry, your question isn't entirely clear: you just want to see the previous year's value for a given measure? Like Sales 2015 vs. Sales 2014?Kyle Hale
Sorry, I see there are some misstake in my text :( Correct is: How do I get something similar for "Calculated field 1"? In other words, I want to get the "C_Total Asset Per Share" in Column D to "jump" one row upward so B26 value will be at D25 and B25 will be at D24. see link: i.stack.imgur.com/DCvoI.png Thanks in advance :PWizhi

1 Answers

3
votes

DAX has time intelligence functions built in, so it's fairly easy to do what you'd like using the SAMEPERIODLASTYEAR function.

First you need a date table joined to your fact table. Then just do

CALCULATE ( [Base Measure], SAMEPERIODLASTYEAR(DateTable[Date]) )