cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
spartan27244
Helper II
Helper II

Calculate a previous period Sum

As in the example on this page SAMEPERIODLASTYEAR function (DAX) - DAX | Microsoft Docs

= CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(DateTime[DateKey]))

 

I too am trying to do the same, my measuer formula is as so

PrevPrdPlanPaid = CALCULATE(Sum(MedClaims[PlanPaid]), SAMEPERIODLASTYEAR(Dates[Date]))
However my visual always shows a blank, when it should show for example in 2019-FY 10,503,949.37 i.e. the 2018-FY value, etc. I know this seems point less but the number will be used to calculate a rate of change which is simple math once I can get the number. I have attached PBX file, well apparently I cannot attach a file so here is the onedrive link
 
 
spartan27244_0-1623952589188.png

My data model is very simple, note the Date table is Marked as a Date Table.

 

spartan27244_1-1623952658935.png

 

 

 

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

For most seansoned DAX users, both cross filtering direction (bi-directions) in data model is time bomb rather than cure-all. At least for me, I rely on mono-directional relations in data model.

Screenshot 2021-06-17 222112.png

Screenshot 2021-06-17 222143.png

Looks like this works

 

PrevPlanPaid =
Var D = DATESBETWEEN(Dates[Date], DateAdd(firstdate(Dates[Date]), -1, year), DATEADD(LASTDATE(Dates[Date]), -1, YEAR))

return CALCULATE(Sum(MedClaims[PlanPaid]), REMOVEFILTERS(ReportPeriods), D)

By removing the bidirectional filter, none of the other visuals are calculated properly

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors