Forum Discussion

wooand's avatar
wooand
Helper II
8 years ago
Solved

Prior Month Summaries.

I need to produce a summary of various stats for different one month periods, for example, last month, two months ago and so on.  I have used this code:

 

1m Ago Volume = CALCULATE(SUM('Results'[USD Amount]),

DATESBETWEEN('Results'[Trade Date],

Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-1)),1),

EOMONTH(today(),-1)))

 

And…

 

2m Ago Volume = CALCULATE(SUM('Results'[USD Amount]),

DATESBETWEEN('Results'[Trade Date],

Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-2)),1),

EOMONTH(today(),-2)))

 

The problem is that I have just updated the data to include January’s data and none of the ‘1m Ago Volume’ or ‘2m Ago Volume’ has updated.  Any ideas what I've done wrong please? 

  • Hi wooand

     

    Give this a shot

     

    1m Ago Volume =
    CALCULATE (
        SUM ( Results[USD Amount] ),
        DATESINPERIOD (
            Results[Trade Date],
            SELECTEDVALUE ( Results[Trade Date] ),
            -2,
            MONTH
        )
    )

     or

     

    1m Ago Volume =
    CALCULATE (
        SUM ( Results[USD Amount] ),
        DATESINPERIOD ( Results[Trade Date], TODAY (), -2, MONTH )
    )

1 Reply

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Hi wooand

     

    Give this a shot

     

    1m Ago Volume =
    CALCULATE (
        SUM ( Results[USD Amount] ),
        DATESINPERIOD (
            Results[Trade Date],
            SELECTEDVALUE ( Results[Trade Date] ),
            -2,
            MONTH
        )
    )

     or

     

    1m Ago Volume =
    CALCULATE (
        SUM ( Results[USD Amount] ),
        DATESINPERIOD ( Results[Trade Date], TODAY (), -2, MONTH )
    )