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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.