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
Palan22
Frequent Visitor

Calculating Sum Based on Current Date Value and Previous Date Values

Hi! 

 

I am trying to calculate the sum of all 'Received' values from the current and any previous postdate by using the following:

 

Change = CALCULATE(SUM(Services[Received]),FILTER(Services,Services[Post Date]<=EARLIER(Services[Post Date])))

 

My issue is that the calculated value for the first date post (12/12/2021) is wrong, I am not even sure where the 44505 value came from. I should be seeing 1935 as the received and change value for 12/12/2021. Am I using the wrong function?

 

Change Calculation.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Palan22 , Better to do this with a date table.

 

Check example

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('order'[Qty]), previousday('Date'[Date]))

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Palan22 , Better to do this with a date table.

 

Check example

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('order'[Qty]), previousday('Date'[Date]))

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

@amitchandak This day example worked for me! Thank you so much!!!! 

@amitchandak Hi! If I want the 'Change' value to be the sum of the current post day 'Received' value and all previous post date 'Received' values, which example would you suggest I use?  In my image example, I posted above, the first date change value is incorrect but anything after that is correct. For example, the post date 02/13/2021 shows a received value of 13 and a change value of 1950 ( received value from 12/12/2021 plus the received value from 12/13/2021), which is correct. I tried the examples you posted but it's only displaying the previous post date values, or a blank section (more than likely due to the fact that I don't have a date table you mentioned).  Thanks for helping me out with this. 

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.