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
heygau
Helper I
Helper I

DAX Help

heygau_0-1709605449108.png

 

I want to calculate the stock on hand as follows:
[(Opening Balance + Bales Received) - Bales Sold].

I need to consider the opening balance from June 2023 and continue with the resulting value in the Stock on Hand column. I only have one value for the opening balance from then onwards; after every month's transaction, I need to know how much stock we have left on hand



Bales Received is a measure = SUM(Bales Received ) and Bales Sold as well, from multiple tables. Thanks.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Please review/study my solution to a similar problem in the attached files and apply the measures/techniques to your dataset.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Please review/study my solution to a similar problem in the attached files and apply the measures/techniques to your dataset.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
heygau
Helper I
Helper I

Hi @amitchandak 

I have to consider the given Opening balance (56,192 )from June 2023 on monthly Basis. Thank you 

amitchandak
Super User
Super User

@heygau , seem like Inventory problem, here we will prefer to use Cumulative measure

 

Inventory / OnHand BOP=
CALCULATE(firstnonblankvalue('Date'[Month]),sum(Table[Intial Inventory]),all('Date')) +
CALCULATE(SUM(Table[Ordered]),filter(all(date),date[date] <min(date[date]))) -
CALCULATE(SUM(Table[Sold]),filter(all(date),date[date] <min(date[date])))

 

 

Inventory / OnHand EOP=
CALCULATE(firstnonblankvalue('Date'[Month]),sum(Table[Intial Inventory]),all('Date')) +
CALCULATE(SUM(Table[Ordered]),filter(all(date),date[date] <=max(date[date]))) -
CALCULATE(SUM(Table[Sold]),filter(all(date),date[date] <=max(date[date])))

 

 

or

 

Inventory / OnHand =
CALCULATE(firstnonblankvalue('Date'[Month]),sum(Table[Intial Inventory]),filter(all(date),date[date] <min(date[date]))) +
CALCULATE(SUM(Table[Ordered]),filter(all(date),date[date] <=max(date[date]))) -
CALCULATE(SUM(Table[Sold]),filter(all(date),date[date] <=max(date[date])))

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.