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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
po
Post Prodigy
Post Prodigy

Get % difference in sales with promotion of product

Hi ,

 

Looking to determine the effect of certain events on sales e.g. promotion of product.

 

e.g. have sales table and rows which flagged if sale occured during event e.g promotion of a product 

customer

, product

, sales_qty

, sale_date

, 'Promotion active_flag'

 

example data

joe bloggs

, beans

,10

,'01-jun-2020'

,'Promotion Active'

 

joe bloggs

, beans

,2

,'01-MAY-2020'

'No promotion'

 

Want to see sales of these 

 

User can select sales date e.g. if select 01-jun-2020' onwards t0 '30-jun-2020', have below

CALCULATE(AVERAGE('Sales'[Sales Qty]),'Epos Sales'[Event Descriptor]="Promotion Active")

However, if say user selects as partciular date, only want the avarge in formula below to take into account the corresponding day of week.  How can we best achieve this?

 

CALCULATE(AVERAGE(' Sales'[Sales Qty]),'Sales'[Event Descriptor]="No Promotion Active",ALL('Sales'[Sales Date]))
 
Thanks

 

4 REPLIES 4
Fowmy
Super User
Super User

@po 

Can you explain this part?

"However, if say user selects as partciular date, only want the avarge in formula below to take into account the corresponding day of week.  How can we best achieve this?"

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi,

 
Thanks for reply.
 
 
What means is that user can select a date via a slicer, which is all dates after promotion started.
 
If say they select a date which is a wednesday, wish to compare the sales on this date to an average of wed sales before the prmotion started 
 
Believe have managed to do this va below but may be better way?
 
 
 
SWITCH(weekday(max('Sales'[Sales Date]),1)-1
,0,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=0)
,1,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=1)
,2,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=2)
,3,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=3)
,4,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=4)
,5,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=5)
,6,CALCULATE(AVERAGE(' Sales'[Sales Qty]),ALL(' Sales'[Sales Date]),' Sales'[ Descriptor]="Before promotion",'Calendar'[Day of Week]=6)
)

@po 

 

Use this measure:

 

 

Sales Before Promo Avg same Week Day = 
VAR _WeekDay =  WEEKDAY(SELECTEDVALUE(Sales[Sales Date]))
RETURN
CALCULATE(
    AVERAGE(Sales[Sales Qty]),
    Sales[Descriptor]="Before promotion",
    FILTER(ALL(Sales),WEEKDAY(Sales[Sales Date])=_WeekDay)
)

 

 

 

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

APPRECIATE KUDOS!


Subscribe to ExcelFort

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thanks - will give it a try

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.