Forum Discussion

Pquinlan21's avatar
Pquinlan21
Frequent Visitor
2 years ago
Solved

Help with Previous Day value Calculation

I could use help with determining why my code is not working. Thank you

 

  • Pquinlan21 Oh, it's a column. Just remove the MAX around the __Date variable calculation and you will be set.

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Pquinlan21 Could be a whole host of things starting with using CALCULATE and DAX TI functions. You can do this simply by using this:

     

    Measure = 
      VAR __Date = MAX('winston (2)'[Date])
      VAR __PrevDay = __Date - 1
      VAR __Result = SUMX( FILTER(ALLSELECTED('winston (2)'), [Date] = __PrevDay), [Daily PPC Natural Gas Burned mcal] )
    RETURN
      __Result

     

    • Pquinlan21's avatar
      Pquinlan21
      Frequent Visitor

      Greg_Deckler It worked to get the value for the previous day but it only provided that value. I would like it to give the previous value for each day if that is possible. I have attache a screen shot showing the results of the previous code. 

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Pquinlan21 Oh, it's a column. Just remove the MAX around the __Date variable calculation and you will be set.