Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Prior Date

I have a table with jobs records by customer and work date...I have the max work date...how do I get the prior work date?

  • Hi Anonymous ,

     

    Does the measure meet your requirement?

    Prior Date = 
    VAR maxd =
        MAXX ( ALL ( 'Table' ), 'Table'[work day] )
    RETURN
        CALCULATE (
            MAX ( 'Table'[work day] ),
            FILTER ( 'Table', 'Table'[work day] <> maxd )
        )
    

     

4 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous ,

     

    Does the measure meet your requirement?

    Prior Date = 
    VAR maxd =
        MAXX ( ALL ( 'Table' ), 'Table'[work day] )
    RETURN
        CALCULATE (
            MAX ( 'Table'[work day] ),
            FILTER ( 'Table', 'Table'[work day] <> maxd )
        )
    

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is great...thx!!!  One more follow-up question...how do I get the sales from that prior date now that I have it?

      • v-frfei-msft's avatar
        v-frfei-msft
        Community Support

        Hi Anonymous ,

         

        Then we should update the measure as below.

         

        Prior Date = 
        VAR maxd =
            MAXX ( ALL ( 'Table' ), 'Table'[work day] )
        RETURN
            CALCULATE (
                MAX ( 'Table'[work day] ),
                FILTER ( ALL('Table'), 'Table'[work day] <> maxd )
            )
        

        To get the sales amount based on Prior date.

        sales amount pri = CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[work day] = [Prior Date]))