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
MarkCBB
Helper V
Helper V

DAX Calculated Column for previous X months

Hi there,

 

I am more of an excel user than DAX, so I am pretty sure a calculated column is not the way to go, but for my understand to grow I would like to see the result in a calculated column before I move this into a Measure.

 

I have a simple fact table that contains the following:

Date 

Store ID

Product ID

Sales

 

I would like to add a calculated column to calculate the previous 3 months (Including the current month until the relivate date). aveage sales (Product & Site)

 

obviously when starting on the first date (i.e. 2016-01-01 there is no history so I am assuming that the result for that row would be the same as the acutaly sales.

 

Hope the above makes sence.

 

note, the table has 7m rows, the average sales works as a "Helper column to calculate another column.

 

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @MarkCBB

 

Can you provide some data and the output expected.

 

Cheers

 

CheenuSing

@MarkCBB

 

You can create a measure with the following formula

 

RT Last 3 Months Sales =
CALCULATE (
SUM(Sheet[Sales]),
DATESINPERIOD (
Sheet[Date].[Date],
LASTDATE ( Sheet[Date].[Date] ),
-3,
MONTH
)
)

 

In this i have stored the data in Sheet. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.