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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Haja007
Regular Visitor

calculated column

Hello everyone, I'm a beginner in power bi and I don't know if my problem is because of my model or something else.

In short, I have a table containing lists of products with several columns including inventory date, end of month stock (stock), quantity consumed during the month (qtCons). I would like to add another column to have the month of stock available (stock/qtCons) on the inventory date, in other words if the inventory date is the end of January, I would like to have the month of stock available (stock January/ consumption average three of the last month). my problem is that once I am on line at the end of January how to recover the average qtCons of November, December and January ?

ProductsstoreInventory dateend of month Stock qtCons during the monthemonth of stock available
Product AS12023-01-31122312/average quantity consumed during the last three months including the month of inventory(november,december,january)
Product BS12023-01-31234323/average quantity consumed during the last three months including the month of inventory(november,december,january)
Product CS12023-01-31322...
Product AS22023-01-31235...
Product BS22023-01-31567...
Product CS22023-01-31760...
................

 

Thank you so much !

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

Hi @Haja007 
 
Assuming that date will always be monthend date. If not please modify the date condition accordingly.
(EOMONTH( _InvDate, -3) + 1) && QtyTbl[Inventory date] <= _InvDate
Above formula first subtracts 3 months from current date and return end of month and +1 to give beginning of next month.
 
New Col =
VAR _Product = QtyTbl[Products]
VAR _Store = QtyTbl[store]
VAR _InvDate = QtyTbl[Inventory date]
VAR avgQtyLast3Mths =
                    CALCULATE(
                                AVERAGE(QtyTbl[qtCons]),
                                REMOVEFILTERS(QtyTbl),
                                QtyTbl[Products] = _Product,
                                QtyTbl[store] = _Store,
                                QtyTbl[Inventory date] >= (EOMONTH( _InvDate, -3) + 1) && QtyTbl[Inventory date] <= _InvDate
                    )
RETURN DIVIDE( QtyTbl[EOMStock ], avgQtyLast3Mths)
 
talespin_1-1707647846361.png

 


 

View solution in original post

1 REPLY 1
talespin
Solution Sage
Solution Sage

Hi @Haja007 
 
Assuming that date will always be monthend date. If not please modify the date condition accordingly.
(EOMONTH( _InvDate, -3) + 1) && QtyTbl[Inventory date] <= _InvDate
Above formula first subtracts 3 months from current date and return end of month and +1 to give beginning of next month.
 
New Col =
VAR _Product = QtyTbl[Products]
VAR _Store = QtyTbl[store]
VAR _InvDate = QtyTbl[Inventory date]
VAR avgQtyLast3Mths =
                    CALCULATE(
                                AVERAGE(QtyTbl[qtCons]),
                                REMOVEFILTERS(QtyTbl),
                                QtyTbl[Products] = _Product,
                                QtyTbl[store] = _Store,
                                QtyTbl[Inventory date] >= (EOMONTH( _InvDate, -3) + 1) && QtyTbl[Inventory date] <= _InvDate
                    )
RETURN DIVIDE( QtyTbl[EOMStock ], avgQtyLast3Mths)
 
talespin_1-1707647846361.png

 


 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.