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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
asuprunova
Frequent Visitor

Help to calculate values to previous period.

Hello, I hope someone will be able to help me with the problem I have. I have a table that specifies student hours by term. For example, I want to know what is the difference in hours between Fall 2020 and Fall 2021. I tried inserting "fake" dates, connected them to the Date dimension table, and implemented the DATEADD function. But it would not give me the result I am looking for. I am suspecting this is because this is not a year-to-year comparison. But I still don't understand why this would not work.  

This is my expression, and I had tables where it work just fine, but not for this one. 

_CH =
VAR _CH =
CALCULATE(CreditHours[_CreditHoursSum], DATEADD(CreditHours[Date],-1,YEAR))
RETURN
_CH
I only have fall semester there, but I do have all semesters in the table I need values for. 
 
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
NilR
Post Patron
Post Patron

VAR _CH =
CALCULATE(SUM(CreditHours[_CreditHoursSum])DATEADD(CreditHours[Date],-1,YEAR))
OR
CALCULATE(SUM(CreditHours[_CreditHoursSum]), PREVIOUSYEAR(CreditHours[Date]))
OR
CALCULATE(SUM(CreditHours[_CreditHoursSum]), SAMEPERIODLASTYEAR(CreditHours[Date]))

Yep, I tried what you offered and it does not return results. Also, in my expression the variable_CreditHoursSum was already a summarization, that is why I skipped SUM in my expression. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.