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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Wadda7AboUdai
Frequent Visitor

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors