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
bchager6
Super User
Super User

Retrieving Sum from Prior Period

Hello all...

 

I'm looking for guidance on how to create a measure/measures that will retrieve the sum total from the prior period, in this case $4.00, that I can then use to subtract from the current period total, in this case $8.00. I will be inserting the difference between the 2 values in a table, sorted by project ID.

Thanks in advance to anyone who can help!

ProjectPeriodInsertedDateValue
A16/1/2020$1.00
B16/1/2020$1.00
C16/1/2020$1.00
D16/1/2020$1.00
A26/15/2020$2.00
B26/15/2020$2.00
C26/15/2020$2.00
D26/15/2020$2.00
1 ACCEPTED SOLUTION

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

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

Will the difference between 2 period always be 14 days?


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

Yes it should be.

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/

@Ashish_Mathur The code works for the periods that end on the 15th of the month, but not for the periods on the first of the month. The expression to produce a value for the previous period is returning blanks for the 1st of the month. Any ideas as to why?

 

Capture.JPG

 

 

Hi,

Share the link from where i can download your PBI file.  CLearly show the result that you are expecting in the blank column.


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

Thank you @Ashish_Mathur . That definitely gets me closer to where I want to be. I need to play around with it a bit more because what I need to see in the June 15 column is what I'm seeing in the Total column.

 

 Capture.JPG

amitchandak
Super User
Super User

@bchager6 , Move period to separate table , say Period

and then try

This Period = CALCULATE(sum('Table'[Value]), FILTER(ALL('Period'),'Period'[Period]=max('Date'[Period])))
Last Period = CALCULATE(sum('Table'[Value]), FILTER(ALL('Period'),'Period'[Period]=max('Date'[Period])-1))

 

Very similar approach I used in Week here

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

@amitchandak  Thanks but I can't move the period to a separate table in this case.

@bchager6 , Try like

This Period = CALCULATE(sum('Table'[Value]), FILTER(ALLSELECTED('Table'),'Table'[Period]=max('Table'[Period])))
Last Period = CALCULATE(sum('Table'[Value]), FILTER(ALLSELECTED('Table'),'Table'[Period]=max('Table'[Period])-1))

Thanks, I'll try that.

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.