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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Consumption of Product based on Next Entry

I am trying to figure out how to calculate how much a product is consumed knowing a constant rate of consumption and the estimated number of days it will take. My goal is to take this and determine if the customer needs to reorder or if they are so far gone that they should be considered 'churn.' This is how my data is structured:

 

CustomerID_ProductIDProduct_NameDays Product LastsDate_SoldProductID_Sold_Index% Consumed
123_ABCNapkins3012/1/201900100%
123_ABCNapkins3012/31/201901100%
123_ABCNapkins301/30/2020025%
456_ABCNapkins6012/15/20190075%
789_DEFWater Bottles3010/1/201900100%
789_DEFWater Bottles3011/1/201901300%

 

What I'm trying to do is take the customers and their products and identify those that are coming up on when they need to order with us (should we email them?) and customers who haven't ordered with us for some time (last row) as potential re-engagements etc. If they already placed their second or third order (see Index), I want their prior order to default to 100% consumption.

 

Thoughts? Ideas on how to do this? Would this be better as a measure rather than a column? Thanks for your help!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous  If you are looking for % consumed measure, please use bleow measure.

Measure = 
VAR _maxIndex = CALCULATE(MAX('Table'[ProductID_Sold_Index]),ALLEXCEPT('Table','Table'[CustomerID_ProductID]))
VAR _dayssincelastpurchase = DATEDIFF(SELECTEDVALUE('Table'[Date_Sold]),TODAY(),DAY)
RETURN IF(SELECTEDVALUE('Table'[ProductID_Sold_Index])<_maxIndex,1,DIVIDE(_dayssincelastpurchase,SELECTEDVALUE('Table'[Days Product Lasts]),0))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous  If you are looking for % consumed measure, please use bleow measure.

Measure = 
VAR _maxIndex = CALCULATE(MAX('Table'[ProductID_Sold_Index]),ALLEXCEPT('Table','Table'[CustomerID_ProductID]))
VAR _dayssincelastpurchase = DATEDIFF(SELECTEDVALUE('Table'[Date_Sold]),TODAY(),DAY)
RETURN IF(SELECTEDVALUE('Table'[ProductID_Sold_Index])<_maxIndex,1,DIVIDE(_dayssincelastpurchase,SELECTEDVALUE('Table'[Days Product Lasts]),0))
Anonymous
Not applicable

Thanks @Anonymous!! Your solution got me 80% of the way there and I was able to figure out the rest based on what you gave me!

 

For those curious as to why it wasn't a 100% solution - our business receives new products from different manufacturers that are essentially the same as existing products (same name, usage). These new products have a new Product ID assigned to them - so the Napkins in my example would be Product ID 123456789 and a new Napkins Product ID might be 124456789. This was causing issues since the new ID would generate a new order Index number, meaning the old product wouldn't see the new order and mark it as 500% consumption. Using just the name (Napkins) would throw an error of 100% for the new product when it was in fact only at 50%.

 

Either way, my solution is below - I had to bring in the actual Product_ID (which is sequential in our system) and create a new field for CustID_Product_Name to enable comparison based on Product Names:

Consump% = 
VAR _maxIndex =             CALCULATE( MAX( 'Table'[ProductID_Sold_Index] ) , ALLEXCEPT('Table' , 'Table'[CustID_Product_Name] ))
VAR _dayssincelastfill =    DATEDIFF( 'Table'[Date_Sold] , TODAY() , DAY )
VAR _maxIDNum =             CALCULATE( MAX( 'Table'[Product_ID] ) , ALLEXCEPT( 'Table' , 'Table'[CustID_Product_Name] ) )
Return 
    IF( _maxRxNum > 'Table'[Product_ID] , 1 ,
        IF(  'Table'[ProductID_Sold_Index]  < _maxIndex , 1 , DIVIDE( _dayssincelastfill , 'Table'[Days Product Lasts]  , 0 )) ) 

 

Thanks again for the help!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.