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
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
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.