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
Anonymous
Not applicable

Work out total number of sales for past 13 month period

Hi,

 

I am wanting to sum the sales

 

(revenue) for the 13 past 13 month in a measure.

 

What would the code be to do this

 

Im thinking something like

 

=Calculate(sum(revenue),datesbetween(dateadd(calender(date),-13,Month),dateadd(today))

But it doesnt work.

 

C

1 ACCEPTED SOLUTION

DateADD shouldn't look at a column but instead I assume you want it to be Today(). This will create a measure that always looks at 13 months from today. If you want 13 months from the selected date then it will need to be something like FirstDate(Calendar1[date]) as the first dateadd paparmeter.

View solution in original post

4 REPLIES 4
Framet
Resolver II
Resolver II

I'm not sure you can have dateadd(today)

what about:

 

=
CALCULATE (
    SUM ( [revenue] ),
    DATESBETWEEN (
        calendar[date],
        DATEADD ( TODAY(), -13MONTH ),
        TODAY ()
    )
)

Anonymous
Not applicable

Thanks for getting back, unfortunatly I am still receiving an error.

 

A table of Multiple values was supplied where a single value was expected

 

I amended the revenue to column3 as that is what it is called in the database. 

 

=CALCULATE (
SUM ( [Column3] ),
DATESBETWEEN (
Calendar1[Date],
DATEADD ( Calendar1[Date], -13, MONTH ),
TODAY ()
)
)

 

DateADD shouldn't look at a column but instead I assume you want it to be Today(). This will create a measure that always looks at 13 months from today. If you want 13 months from the selected date then it will need to be something like FirstDate(Calendar1[date]) as the first dateadd paparmeter.
Anonymous
Not applicable

Brill! Works a treat!

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.