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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
User_790790
Regular Visitor

Calculate stock in hand from initial date

I have the following table below :- 

 

The remaining stock in hand from the end of the month (30th sep) is 30. 

 

I need to calculate stock in hand like this

01-10-2024 Stock in hand = Stock in hand end of month + Quantity Issued on 1st - QTY Sold
                                          = 30 + 5 - 2
                                          = 33

Then the remaining stock from the previous day to be added with qty issued like the below 
02-10-2024 Stock In Hand = 33 + 6 - 7 = 32

 

How can I replicate this in Power bi?

 

 

DateItem NameSalesmanQuantity IssuedQty SoldStock In Hand
01-10-24TVJohn5233
02-10-24TVJohn6732
03-10-24TVJohn13639
04-10-24TVJohn14350
05-10-24TVJohn5649
06-10-24TVJohn5747
07-10-24TVJohn3842
08-10-24TVJohn10943
09-10-24TVJohn6247
10-10-24TVJohn9650
11-10-24TVJohn6353
12-10-24TVJohn61049
3 ACCEPTED SOLUTIONS
ThxAlot
Super User
Super User

ThxAlot_0-1735364478313.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

sanalytics
Super User
Super User

@User_790790 
In case you want to achieve this result as measure instead of calculated column.
Below are the code

EOD SIH = 30
//It emans Sep's Stock in Hand
StockInhand = 
VAR _QtyIssueRT = 
CALCULATE(
    SUM( 'Table'[Quantity Issued] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] <= MAX( 'Table'[Date] )
    ) )
VAR _QtySoldRT = 
CALCULATE(
    SUM( 'Table'[Qty Sold] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] <= MAX( 'Table'[Date] )
    ) )
VAR _Result = 
[EOD SIH] + _QtyIssueRT - _QtySoldRT
RETURN
_Result

Below screenshot

sanalytics_0-1735380036920.png

Let me know if you need help for end of the mnth stock in hand.

 

Hope it helps.

 

Regards,

sanalytics



View solution in original post

pcoley
Impactful Individual
Impactful Individual

@User_790790 
Do you need a calculated column or a measure?
If it is a measure please be more precise about the model (tables and relationships available) and the existing context in the report. actually that measure correspond to a running total with the measure

stock= SUM ('Table'[Quantity Issued]) - SUM ('Table'[Qty Sold])

if all the columns are placed in the same "Table" then this measure could work:

Measure Stock in hand=
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL('Table'), 'Table'[Date] <= MAX('Table'[Date] ) )
)
​


if you need a calculated column please use this CalcColumn Dax formula: 
--> changing the "table" with your actual table name.

😁Column =
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
)


I hope this helps, if so please accept as a solution. Kudos are welcome😁.

If I helped solve your problem, mark this post as a solution.
Kudos are Welcome! | AI assisted for clarity of wording. |

View solution in original post

4 REPLIES 4
pcoley
Impactful Individual
Impactful Individual

@User_790790 
Do you need a calculated column or a measure?
If it is a measure please be more precise about the model (tables and relationships available) and the existing context in the report. actually that measure correspond to a running total with the measure

stock= SUM ('Table'[Quantity Issued]) - SUM ('Table'[Qty Sold])

if all the columns are placed in the same "Table" then this measure could work:

Measure Stock in hand=
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL('Table'), 'Table'[Date] <= MAX('Table'[Date] ) )
)
​


if you need a calculated column please use this CalcColumn Dax formula: 
--> changing the "table" with your actual table name.

😁Column =
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
)


I hope this helps, if so please accept as a solution. Kudos are welcome😁.

If I helped solve your problem, mark this post as a solution.
Kudos are Welcome! | AI assisted for clarity of wording. |

Thanks, i'll check it out. Sorry for the lack of clarity. I have three tables one is stock in hand from prev month, quantity issued, sales data. I would like to get the result in a new table if it's possible.

https://docs.google.com/spreadsheets/d/1mqJBUTHIwDU380uukvLYloHRgZsnS6Mz/edit?usp=sharing&ouid=10407... 

sanalytics
Super User
Super User

@User_790790 
In case you want to achieve this result as measure instead of calculated column.
Below are the code

EOD SIH = 30
//It emans Sep's Stock in Hand
StockInhand = 
VAR _QtyIssueRT = 
CALCULATE(
    SUM( 'Table'[Quantity Issued] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] <= MAX( 'Table'[Date] )
    ) )
VAR _QtySoldRT = 
CALCULATE(
    SUM( 'Table'[Qty Sold] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] <= MAX( 'Table'[Date] )
    ) )
VAR _Result = 
[EOD SIH] + _QtyIssueRT - _QtySoldRT
RETURN
_Result

Below screenshot

sanalytics_0-1735380036920.png

Let me know if you need help for end of the mnth stock in hand.

 

Hope it helps.

 

Regards,

sanalytics



ThxAlot
Super User
Super User

ThxAlot_0-1735364478313.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.