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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
SriGanesh
Regular Visitor

Calculate formula in Power BI

I have use the below Formula in Power BI and it is working fine if i choose 2023 and 2024 year both. If i choose alone 2024. It is not sum the Previous 2 months ie. 2023 year  Nov and Dec.

 

Power BI formula I used- 

CALCULATE(SUM('REPAIR_UNIT_SUMMARY'[OBF_NUMERATOR]),DATESINPERIOD('REPAIR_UNIT_SUMMARY'[MONTHYEAR],LASTDATE('REPAIR_UNIT_SUMMARY'[MONTHYEAR]),-3,MONTH)).
 
help required to reslove this issues
3 REPLIES 3
bhanu_gautam
Super User
Super User

@SriGanesh , Try using this formula this uses ALLfunction

 

CALCULATE(
SUM('REPAIR_UNIT_SUMMARY'[OBF_NUMERATOR]),
DATESINPERIOD(
'REPAIR_UNIT_SUMMARY'[MONTHYEAR],
LASTDATE(ALL('REPAIR_UNIT_SUMMARY'[MONTHYEAR])),
-3,
MONTH
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






It is calculating the Same value for all the rows.

SriGanesh_1-1720696456273.png

 

DAX
CALCULATE(
SUM('REPAIR_UNIT_SUMMARY'[OBF_NUMERATOR]),
DATESINPERIOD(
'REPAIR_UNIT_SUMMARY'[MONTHYEAR],
LASTDATE('REPAIR_UNIT_SUMMARY'[MONTHYEAR]),
-3,
MONTH
),
PARALLELPERIOD(
'REPAIR_UNIT_SUMMARY'[MONTHYEAR],
-1,
YEAR
)
),

 

Try using this or share sample date




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.