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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SelenaZ
Regular Visitor

CALCULATING PROMO SALES IN DIFFERENT STORES OVER UNIQUE PERIODS

Hi everyone,

 

I have the following challenge.

One table contains sales in different stores (fields StoreID, SalesDate, ProductID, SalesQty)

The other table containes only the stores selected for promotions (fields StoreID, PromoStart, PromoEnd).

 

How do I calculate the sum of all products sold on Promo in all thes stores, given that the period of Promo can be unique for every store? In other words, I need a measure showing the total promo sales of all stores in a specific period of time (given by Pivot Filter), knowing that some stores were selling Promo only for a partial period, and some did not sell at all.

 

Currently I use INTERSECT  to look only at stores that had promos, but I cannot factor in the unique period for each store.

 

Could you please help?

Many thanks!

SelenaZ

 

2 ACCEPTED SOLUTIONS

first to create a date table and mark it as date table, then create a relationship bewteen dates[date] and sales[date]

and try these code

 

Promot_QTY :=
SUMX (
    Promot,
    VAR store = Promot[Store ID]
    RETURN
        CALCULATE (
            SUM ( Sales[Qty] ),
            KEEPFILTERS ( DATESBETWEEN ( Dates[Date], Promot[StartDate], Promot[EndDate] ) ),
            Sales[StoreID] = store
        )
)
unPromot_QTY:=SUM(Sales[Qty])-[Promot_QTY]

 

 

 

 

View solution in original post

you can custom your date table, using date functions to add week column

View solution in original post

9 REPLIES 9
amitchandak
Super User
Super User

@SelenaZ , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Table promotions

 

Store IDPromo NameStartDateEndDate
CT0101Event0101/01/202001/02/2020
CT0102Event0115/01/202015/02/2020
CT0103Event0101/02/202001/03/2020

 

Table Sales

StoreIDDateProductIDQty
CT010102/01/2020Product 110
CT010102/01/2020Product 210
CT010102/02/2020Product 110
CT010102/02/2020Product 210
CT010214/01/2020Product 110
CT010220/01/2020Product 110
CT010220/01/2020Product 110
CT010216/02/2020Product 110
CT010315/01/2020Product 110
CT010320/01/2020Product 210
CT010313/02/2020Product 210
CT010320/02/2020Product 210
CT010301/03/2020Product 25

 

Sample output

MonthPromoNon-Promo
January4030
February2030
March50

 

Thank you for your help!

first to create a date table and mark it as date table, then create a relationship bewteen dates[date] and sales[date]

and try these code

 

Promot_QTY :=
SUMX (
    Promot,
    VAR store = Promot[Store ID]
    RETURN
        CALCULATE (
            SUM ( Sales[Qty] ),
            KEEPFILTERS ( DATESBETWEEN ( Dates[Date], Promot[StartDate], Promot[EndDate] ) ),
            Sales[StoreID] = store
        )
)
unPromot_QTY:=SUM(Sales[Qty])-[Promot_QTY]

 

 

 

 

 
@wdx223_Daniel thank you so much!
One more question: how can I be able to break down sales by month (Month is in the Date Table)
 
 

are you mean putting the month field on the row of matrix?

Well, when I try to break down the results (promo and non-promo sales) by a time period, I can get sales by month but not by week, although my calendar table does include week numbers as well. Could it be an innate DAX limitation?

Thank you1

 

you can custom your date table, using date functions to add week column

@wdx223_Daniel Initially breaking dow by week did not work, but now (after restart) it does. Thank you for your help! Cheers!

 

 

 

 

 

How can I share a file in this environment?

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.