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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Mike91
Helper I
Helper I

Calculate sales before,during and after promorion period

Hi All,

 

i need your helpe, i try to calculate for each item involed in promotion, the 4 week sales before, during the promotion and the 4 week after. i want use the promotion like a filter, to be able chose the promotion and analyze the impact in the sales. i tried different approach but i can't reach my goal specially to calculate the periodo before and after the promotion.

 

Thanks all

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you Ritaf1983 

Hi, @Mike91 

Based on the PBIX file you provided, I use the following two DAX expressions to create a measure to find the date 4 weeks before the promotion and the date 4 weeks after the promotion.

Four Week before = 
VAR _start_day = MAX('Promo'[Start Date])
var _before_four_week = _start_day - 28
RETURN _before_four_week
Four Week after = 
VAR _end_day = MAX('Promo'[End Date])
var _after_four_week = _end_day + 28
RETURN _after_four_week

I created a measure for each of these three phases:

Four week before sales = 
VAR _end_day = MAX('Promo'[Start Date])
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER('Sales','Sales'[Date]>[Four Week before]&&'Sales'[Date]<_end_day))
Four week after sales = 
VAR _start_day = MAX('Promo'[End Date])
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER('Sales','Sales'[Date]>_start_day&&'Sales'[Date]<[Four Week after]))
During promotion sales = 
VAR _start_day = MAX('Promo'[Start Date])
VAR _end_day = MAX('Promo'[End Date])
RETURN CALCULATE(SUM(Sales[Sales]),FILTER('Sales','Sales'[Date]>=_start_day&&'Sales'[Date]<=_end_day))

Modify the table relationship as follows:

vjianpengmsft_0-1728360849303.png

The results are as follows:

vjianpengmsft_1-1728360888213.png

vjianpengmsft_2-1728360913285.png

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thank you Ritaf1983 

Hi, @Mike91 

Based on the PBIX file you provided, I use the following two DAX expressions to create a measure to find the date 4 weeks before the promotion and the date 4 weeks after the promotion.

Four Week before = 
VAR _start_day = MAX('Promo'[Start Date])
var _before_four_week = _start_day - 28
RETURN _before_four_week
Four Week after = 
VAR _end_day = MAX('Promo'[End Date])
var _after_four_week = _end_day + 28
RETURN _after_four_week

I created a measure for each of these three phases:

Four week before sales = 
VAR _end_day = MAX('Promo'[Start Date])
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER('Sales','Sales'[Date]>[Four Week before]&&'Sales'[Date]<_end_day))
Four week after sales = 
VAR _start_day = MAX('Promo'[End Date])
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER('Sales','Sales'[Date]>_start_day&&'Sales'[Date]<[Four Week after]))
During promotion sales = 
VAR _start_day = MAX('Promo'[Start Date])
VAR _end_day = MAX('Promo'[End Date])
RETURN CALCULATE(SUM(Sales[Sales]),FILTER('Sales','Sales'[Date]>=_start_day&&'Sales'[Date]<=_end_day))

Modify the table relationship as follows:

vjianpengmsft_0-1728360849303.png

The results are as follows:

vjianpengmsft_1-1728360888213.png

vjianpengmsft_2-1728360913285.png

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

it's working, but if i try to add another Item, without any promotion this "appear" in my table to see only the pormotion perfomance.

Mike91_0-1728632921593.png

 

Ritaf1983
Super User
Super User

Hi @Mike91 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi Rita,  this is the link where you can find the power bi structure it's the same i use in my original works. 

 

https://drive.google.com/file/d/1MkQ9F9n1AXpZuRkwzpF1WNdiZ6XNX7yQ/view?usp=drive_link

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.