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
Whitewater100
Solution Sage
Solution Sage

Daily Avg Sales - Combining Two Time Periods

Hello:

I'm seeking input on how to calculate (efficiently) a daily average for sales for two weeks (can be a month) before and two weeks after a promotional period. The promotional period example is in a separate table called Ad_Campaigns. Here is a shot of the info:

CampaignStartEndMarketing SpendBrandYearDiscount%
Spring-Easter -5% Off3/29/20204/11/2020 $       660LookSharp20200.05
Spring-Easter -5% Off3/29/20204/11/2020 $       396SmoothDrive20200.05
Spring-Easter -5% Off3/29/20204/11/2020 $       396Stealth20200.05
Spring-Easter -5% Off3/29/20204/11/2020 $    1,848ZEGO20200.05

 

I'm able to figure out how to calculate sales during this period but combining two periods to get an average is my question.

I have a date table and sales table.  I'll paste below. Thanks much!

Whitewater100_0-1643220832727.png

 

8 REPLIES 8
Anonymous
Not applicable

Hi @Whitewater100 ,

you can drop your file to attach.

vpollymsft_0-1643864871880.png

Best Regards

Community Support Team _ Polly

 

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

 

Hi Polly:

Please find the file. Thank you for your assistance. 

Anonymous
Not applicable

Hi @Whitewater100 , 

I have created a simple sample. Please refer to it to see if it helps you.

Measure
= var national_= IF(SELECTEDVALUE('Table'[date])>=DATE(2021,10,1)&&SELECTEDVALUE('Table'[date])<=DATE(2021,10,7),"National day",BLANK())
var result = CALCULATE(AVERAGE('Table'[Marketing]),FILTER(ALL('Table'),ISBLANK(national_)))
var holiday_average= CALCULATE(AVERAGE('Table'[Marketing]),FILTER(ALL('Table'),'Table'[date]>=DATE(2021,10,1)&&'Table'[date]<=DATE(2021,10,7)))
return 
IF(SELECTEDVALUE('Table'[date])>=DATE(2021,10,1)&&SELECTEDVALUE('Table'[date])<=DATE(2021,10,7),holiday_average,result)

vpollymsft_0-1643687188668.png

If I have misunderstand your meaning, pleasae provide your pbix without privacy information and desired output.

 

Best Regards

Community Support Team _ Polly

 

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

 

Hello:

 

I had planned to attach my file, however, I do not see where to attach my file here. Can you tell me the best way to send?

 

Thank you

Hello and thank you:

 

For example the Fall 2021 Ad is from 10-30-21 to 11-19-21.

 

I take a measure for two weeks before and two weeks after.

Fall'21 Pre-Ad AUPD = CALCULATE(
AVERAGEX(Dates,
[Units]),
DATESBETWEEN(Dates[Date],
Date(2021, 10, 16), Date(2021, 10, 29)
)
Then 2 Weeks after
Fall'21 Post-AD AUPD = CALCULATE(
AVERAGEX(Dates,
[Units]),
DATESBETWEEN(Dates[Date],
Date(2021, 11, 20), Date(2021, 12, 4)
)
)
 
Then I average them. This is my question how to do these three steps more efficiently:
Fall '21 Base = ([Fall'21 Post-AD AUPD] + [Fall'21 Pre-Ad AUPD])/2
 
Ideally, the number of days to analyze both before and after the ad is equal to the number of the days the ad ran. But for now I was seeking a better way to come up with the average combining the time periods of before and after.
 
Thanks to both of you for replying!
 
)
Anonymous
Not applicable

Hi @Whitewater100 , 

 If your formula works well, please have a try.

Fall '21 Base=
 var Fall'21 Pre-Ad AUPD =
CALCULATE (
    AVERAGEX ( Dates, [Units] ),
    DATESBETWEEN ( Dates[Date], DATE ( 2021, 10, 16 ), DATE ( 2021, 10, 29 ) )
)
var Fall'21 Post-AD AUPD =
CALCULATE (
    AVERAGEX ( Dates, [Units] ),
    DATESBETWEEN ( Dates[Date], DATE ( 2021, 11, 20 ), DATE ( 2021, 12, 4 ) )
)
return
(Fall'21 Post-AD AUPD- Fall'21 Pre-Ad AUPD)/2

If I have misunderstood your meaning, please provide your pbix without privacy information and desired output.

 

Best Regards

Community Support Team _ Polly

 

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

 

 

amitchandak
Super User
Super User

@Whitewater100 , if you already have a sales measure for the period. you can try a measure

 

averaged(values('Date'[Date]), [sales period])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you for replying. I have the sales periods (Pre & Post) promotion. e.g, 

Spring '21 Pre-Ad AUPD = CALCULATE(
AVERAGEX(Dates,
[Units]),
DATESBETWEEN(Dates[Date],
Date(2021, 3, 7), Date(2021, 3, 20)
),
FILTER(Products,
Products[Brand] IN {"LookSharp", "SmoothDrive", "Stealth", "ZEGO"}
)
)
and
Spring '21 Pre-Ad AUPD = CALCULATE(
AVERAGEX(Dates,
[Units]),
DATESBETWEEN(Dates[Date],
Date(2021, 3, 7), Date(2021, 3, 20)
),
FILTER(Products,
Products[Brand] IN {"LookSharp", "SmoothDrive", "Stealth", "ZEGO"}
)
)
 
But my question is how to combine the pre and post into one measure.
 
Thank you.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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