Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Eriko
Frequent Visitor

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.Woman Sad

 

 

Eriko.

1 ACCEPTED SOLUTION

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.

View solution in original post

10 REPLIES 10
disha_khanna
Regular Visitor

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?

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. 

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

Should use DATE column rather than MONTH.
PrevMonthRev = CALCULATE(sum(salesdata[revenue]),PREVIOUSMONTH('date'[DATE]))
Anonymous
Not applicable

Thank you for suggesting this, I made a change that worked for calculating the day over day using this methodology:

 

NON-WORKING EXAMPLE:

aov dod% =
    VAR __PREV_DAY =
        CALCULATE(
            SUM('20200918__Dailies'[aov]),
            PREVIOUSDAY('20200918__Dailies'[inv_date].[date])
        )
    RETURN
        DIVIDE(SUM('20200918__Dailies'[aov]) - __PREV_DAY, __PREV_DAY)
 
SOLUTION:
1.  Imported a date table
2.  Joined the date and the inv_date in relationships
3.  Modified column name referenced below
 

WORKING EXAMPLE:

aov dod% =
    VAR __PREV_DAY =
        CALCULATE(
            SUM('20200918__Dailies'[aov]),
            PREVIOUSDAY('20200918__Dailies'[inv_date])
        )
    RETURN
        DIVIDE(SUM('20200918__Dailies'[aov]) - __PREV_DAY, __PREV_DAY)

date table

DateKeyYearMonth
120151-Jan
220151-Feb
320151-Mar
420151-Apr
520151-May
620151-Jun
720151-Jul
820151-Aug
920151-Sep
1020151-Oct
1120151-Nov
1220151-Dec
1320161-Jan
1420161-Feb
1520161-Mar
1620161-Apr
1720161-May
1820161-Jun
1920161-Jul
2020161-Aug

sales table 

 

DateKeyrevenue
1123
2234
3345
4456
5567
6678
7789
88910
991011
10101112
11111213
12121314
13231
14248
15391
16487
17598
18694
19799
208980
Greg_Deckler
Super User
Super User

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.