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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Wadda7AboUdai
Helper I
Helper I

calculate sales base on last price lowering date

Hello every one 

 

I want to calculate  the qty and sales for every item base on last lower price date until today and the calculation filtered by every branch as the following 

 

itemidlastlowerpricedateoldpricenewpricesales qtysalesbranch
0101-01-2023100501050001
0222-03-202370302266002

 

Note : the seles should start  claculate from the lastlowerpricedate for each item and ignore any sales before the lastlowerpricedate

 

I have these tables 

ITem Table

itemidname
01toy
02t-shirt

lowerpricetabel

itemlower price dateold pricenewpriceqtybranch
0101-01-2023100502301
0201-02-20231207022202
0222-03-202370302701

sales Table

itemidsalesqtydatebranch
01200501-02-202301
01300513-02-202301
026602201-04-202302

 

 

 

1 ACCEPTED SOLUTION

Thank you @johnt75  for your reply 
I used this measure which I got from microsoft being chat 

Sales = CALCULATE(SUM(Sales[sales]),
FILTER(Sales, Sales[Itemid] = MAX(lowerpricetable[itemid]) &&
Sales[branch] = MAX(lowerpricetable[branch]) &&
Sales[Date] >= MAX(lowerpricetable[date])))
it works with me fine .

thanks  

 

 

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Try

Sales since lower price date =
VAR SummaryTable =
    ADDCOLUMNS (
        VALUES ( 'items'[item id] ),
        "@lower price date", CALCULATE ( MAX ( 'lower price table'[lower price date] ) )
    )
VAR Result =
    SUMX (
        SummaryTable,
        CALCULATE (
            SUM ( sales[sales] ),
            DATESBETWEEN ( 'Date'[Date], [@lower price date], TODAY () )
        )
    )
RETURN
    Result

Thank you @johnt75  for your reply 
I used this measure which I got from microsoft being chat 

Sales = CALCULATE(SUM(Sales[sales]),
FILTER(Sales, Sales[Itemid] = MAX(lowerpricetable[itemid]) &&
Sales[branch] = MAX(lowerpricetable[branch]) &&
Sales[Date] >= MAX(lowerpricetable[date])))
it works with me fine .

thanks  

 

 

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.