Forum Discussion

Eriko's avatar
Eriko
Frequent Visitor
10 years ago
Solved

Calculate the month-over-month

Hello.

 

There are a table "Sales" and a table "Date".

 

I want to do is the following.

 

1. Outputs Sales Amount of every month.
2. Calculate the month-over-month.

 

I referenced this site,but error came out.

 

■Site:

http://www.daxpatterns.com/time-patterns/#complete-aggregation-patterns

「Complete Period Comparison Patterns」

 

■Error Message:

A table of the value of the plural was designated, but the necessary value is only one.

 

How should it be done?
Please tell me.:womansad:

 

 

Eriko.

  • procyon82's avatar
    procyon82
    10 years ago

    Just tried something like this which gives me the previous month

     

    Previous month = CALCULATE(SUM('GA Ecommerce'[Sales]),PREVIOUSMONTH('GA Ecommerce'[Date]))

    or

    Previous Month = CALCULATE(SUM('GA Ecommerce'[Sales]),DATEADD('GA Ecommerce'[Date],-1,MONTH))

     

    Should be pretty easy to do MOM from this.

10 Replies

  • I'm facing an issue while calculating previous month sales for the following data:

     

    TimeIDDateFY FYQuarterMonth
    14/1/201320131April
    24/1/201420141April
    34/1/201520151April
    48/1/201320132August
    58/1/201420142August
    68/1/201520152August
    712/1/201320133December
    812/1/201420143December
    912/1/201520153December
    102/1/201420134February
    112/1/201520144February
    122/1/201620154February
    131/1/201420134January
    141/1/201620154January
    157/1/201320132July
    167/1/201420142July
    177/1/201520152July

     

    I simply have the month and Year information. The day information was not available in th raw data and the 1st day in every date is added by me. This Date table stores the Fiscal year that begins in April.

    I have calculated the revenue using Sales from a Fact Table. I now want to calculate the previous month's revenue. I used the DATEADD Function as shown below:

    LastMonthRev = CALCULATE([Revenue],FILTER(DimTime,DATEADD(DimTime[Date],-1,MONTH)))

     

    However I get the same value as this month's revenue(refer the table shown below)

    MonthRevenueLastMonthRev
    1$10.00$10
    2$20.00$20
    3$30.00$30
    4$40.00 
    5$50.00$50
    6$60.00$60
    7$70.00$70
    8$80.00$80
    9$90.00$90
    10$100.00$100
    11$110.00$110
    12$120.00$120

    This data is just for one year. Can someone help me in performing month over month calculations or just getting the last month's revenue correctly?

    • neetishrai's avatar
      neetishrai
      New Member

      did anybody get the solution for this

      i am using PrevMonthRev = CALCULATE(sum(salesdata[revenue]),PREVIOUSMONTH('date'[Month])) but it is not giving any data

      • Jozw126's avatar
        Jozw126
        Regular Visitor
        Should use DATE column rather than MONTH.
        PrevMonthRev = CALCULATE(sum(salesdata[revenue]),PREVIOUSMONTH('date'[DATE]))
    • Jmenas's avatar
      Jmenas
      Icon for Advocate III rankAdvocate III

      Thanks a lot disha_khannayou spare me so much time! thel Filter  help to what i was missing! but still have some issues with the MoM comparison. 

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Can you post some sample data and your formula. From your error, it looks like one of your functions is returning a table when a single column is expected, or something along those lines.

    • procyon82's avatar
      procyon82
      Icon for Resolver I rankResolver I

      Just tried something like this which gives me the previous month

       

      Previous month = CALCULATE(SUM('GA Ecommerce'[Sales]),PREVIOUSMONTH('GA Ecommerce'[Date]))

      or

      Previous Month = CALCULATE(SUM('GA Ecommerce'[Sales]),DATEADD('GA Ecommerce'[Date],-1,MONTH))

       

      Should be pretty easy to do MOM from this.