Juned Ansari
Juned Ansari

Reputation: 5275

How to Create Calculated field for last 7 days sales

I am trying to create one calculated field for last 7 days and want to display same info for like total order value,Total orders, Total Ordering retailers enter image description here

My Formula for Calculated Field

IF ATTR([CreatedDate])>=TOTAL(MAX([CreatedDate]))-6 THEN 
    SUM([OrderAmount])
END

Upvotes: 0

Views: 3175

Answers (2)

Dharmi Naveen
Dharmi Naveen

Reputation: 11

create calculation :

[order Date] >= (TODAY()-7)

drag this calculation into filter and select TRUE

Upvotes: 1

Ben P
Ben P

Reputation: 3379

Create a new calculated field called [Day Index] that indexes your date field by day:

DATEDIFF('day', [Date], today())

Then a new field per measure to get the value for the last 7 days:

IF [Day Index] <= 6 THEN [Total Orders] END

The 6 assures you data source includes the current day also, if it doesn't then you may want to adjust this to 7.

Upvotes: 2

Related Questions