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