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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
charlessutton
Frequent Visitor

Calculating a balance for the next 6 months.

I have a scenario that I am having a hard time explaining and hope that I can clearly word this. 

I have a requirement to calculate raw material balances for the existing and the next 5 months. The current month "OpenBalance" is pulled from a table without a date. It is just the current inventory balance. The subsequent months balances are created by subtracting forecast and consumption and adding purchase orders. I can calcualte everything I need using measures for each month e.g. Month 0, Month 1, Month 2, Month 3, Month 4, Month 5. However, I cannot seem to get these measures to associate with Dates. I am drawing a blank. 

In this example I am using a switch command to calculate the value of the CC_MonthValue however, it is not taking the selection into consideration. I have highlighted an example. The value for M_openbalfinal0 is the correct value but when I try to pull the value up using the swictch command I get a the total for every stock code not just the stock code I have selected via slicer. 

 

charlessutton_0-1629732187935.png

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@charlessutton , You need a measure like

 

sum(Table1[Opening Balance])
+ CALCULATE(SUM(Table[Purchase]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))
- CALCULATE(SUM(Table[sales]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

View solution in original post

2 REPLIES 2
v-xulin-mstf
Community Support
Community Support

Hi @charlessutton

 

You can filter the stock code you have selected via slicer with ALLSELECTED function.

Could you provide your MEASURE?

 

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

amitchandak
Super User
Super User

@charlessutton , You need a measure like

 

sum(Table1[Opening Balance])
+ CALCULATE(SUM(Table[Purchase]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))
- CALCULATE(SUM(Table[sales]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.