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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
goyalsa
Helper III
Helper III

Running calculation bug

Hi all,

 

I am struggling to figure this out. Would really appreciate your help.

goyalsa_0-1647596017469.png

 

Scenario:

In the Stock overview matrix, I have total supply and total demand. The Gross Inventory = Total Supply - Total Demand and then the gross inventory for 202211 will be starting stock for 202212.

 

Gross Inventory Measure = 

Gross Inventory = CALCULATE([Total Supply]-[Total Demand], FILTER(ALLSELECTED(Dates),Dates[Loadingweek] <= MAX(Dates[Loadingweek])))

 

But the problem is sometimes I get the total demand -ve and at that time I do not want to include that total demand in the calculation. Then I want to take Forecasted demand from the Demand Matrix. 

 

Thank you in advance!!

2 REPLIES 2
amitchandak
Super User
Super User

@goyalsa ,

Gross Inventory Measure =
Gross Inventory = CALCULATE([Total Supply]-if([Total Demand]>0,[Total Demand],0) , FILTER(ALLSELECTED(Dates),Dates[Loadingweek] <= MAX(Dates[Loadingweek])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

There is still no difference in the result.

goyalsa_0-1647924012187.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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