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
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


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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

Top Solution Authors