Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago

error in formula dax

good afternoon, I have a design

mancemo_0-1654543865010.png

I capture the year and month of the slicer, I need to get a value for the same period of a year before, for which I make the following formula

mes_ant = DATEADD(Hoja1[my],-1,YEAR)
where I subtract a year to the selected value, until there well because I get the following values
mancemo_1-1654543944226.png

now I need to add the value of the column for that month I use this

total_mes_ant = calculate(SUM(Hoja1[Value]),FILTER(Hoja1,Hoja1[my]=[mes_ant]))
but with that formula it generates emptiness
mancemo_2-1654543986000.png

but in the table if there data

mancemo_3-1654544012257.png

what can be my mistake?

9 Replies

  • - show your data model

    - consider using SAMEPERIODLASTYEAR()

  • I currently only have one table as shown in the image

    mancemo_0-1654696851970.png

    what I want is from selecting a month

    mancemo_1-1654696893316.png

    get the value of the value column for a previous year and the previous month

    • lbendlin's avatar
      lbendlin
      Super User

      You need to modify the filter context to include the full table, by using ALL() or similar.

      • Syndicate_Admin's avatar
        Syndicate_Admin
        Administrator

        hello, what a pity it is not very clear to me how to do it, you help me on the formula as serious that pity

        total_mes_ant = calculate(SUM(Hoja1[Value]),FILTER(Hoja1,Hoja1[my]=[mes_ant]))