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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Using Values from Previous Dates

I have an issue where I would like for a month to show the 67% of the company's value for 2 months ago plus 33% of the company's value for the previous month as I would like to try to compare the values to the current month's sales (could be in 2 different tables ). I added a column (Next month) that would project the next month out. I wrote the following code that I thought would accomplish this but I am getting odd results

 

Pushed Amount = 
var amount = Sheet2[Sale Amount]
var month1 = Sheet2[Next Date]
var month2 = PREVIOUSMONTH(Sheet2[Next Date])
var dealdate =Sheet2[Deal Date]
var saleamount = Sheet2[Sale Amount]
var company = Sheet2[Company]
var pushamount = 
iferror(CALCULATE(SUM(Sheet2[Sale Amount]), Sheet2[Deal Date] = month2,Sheet2[Company] = company),0)*.67 + iferror(CALCULATE(SUM(Sheet2[Sale Amount]), Sheet2[Deal Date] = month1, Sheet2[Company] = company),0)*.33

return
pushamount 

These are the results that I am getting: 

powerbi1.PNG

 

Should produce the same values as in the table below:

powerbi2.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved this by creating a date table and a mesaure, code for the measure below

 

Measure = 
var month1 = CALCULATE(SUM(Sheet2[Sale Amount]),DATEADD('date'[Date],-1,MONTH))
var month2 = CALCULATE(SUM(Sheet2[Sale Amount]),DATEADD('date'[Date],-2,MONTH))
return
.33*month1+.67*month2

One thing that tripped me up was using the incorrect date column when creating visualizations. I was using the one in my original table when I should have been using the one from the date table. If you are getting the exact same number in the same month then this is likely why

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Why do you want that result as a calculated column - why not a measure?  Share the link from where i can download the PBI file.


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

I'm open to using a measure instead, I'm not sure when to use one instead of another

Anonymous
Not applicable

Solved this by creating a date table and a mesaure, code for the measure below

 

Measure = 
var month1 = CALCULATE(SUM(Sheet2[Sale Amount]),DATEADD('date'[Date],-1,MONTH))
var month2 = CALCULATE(SUM(Sheet2[Sale Amount]),DATEADD('date'[Date],-2,MONTH))
return
.33*month1+.67*month2

One thing that tripped me up was using the incorrect date column when creating visualizations. I was using the one in my original table when I should have been using the one from the date table. If you are getting the exact same number in the same month then this is likely why

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors
Top Kudoed Authors