cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
goyalsa
Helper II
Helper II

Take last week result into next week calculation

Hi All,

 

I could not find out the error behind this calculation. 

I want to take the last week's Gross Inventory as a supply for next week and run the calculation but it is giving me an error for a week "202142".

goyalsa_0-1633868735358.png

 

Measure =  

_Gross Inventory = CALCULATE([_Total Supply measure]-[_Gross demand], FILTER(ALLSELECTED(Dates),Dates[Loadingweek] <= MAX(Dates[Loadingweek])))
 
Please help!!!!
 
6 REPLIES 6
v-easonf-msft
Community Support
Community Support

Hi, @goyalsa 

Some fields in the mesure are not shown in the screenshot.

Please share a sample file for further research.

 

Best Regards,
Community Support Team _ Eason

AllisonKennedy
Super User
Super User

@goyalsa  What is the 'error' that you're getting? Or what values do you expect?

 

What is the DAX for Total Supply and Gross demand measures referenced in your Gross Inventory? 

 

What does your model view look like with relationships between the tables?


Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy@v-easonf-msft 

 

The Gross inventory number is not showing correctly,

I am trying to take last week's Gross Inventory and then adding the next week's Supply and subtracting the next week's demand.

The formula should be run like this but it is not working for now.

Gross Inventory(202144) = Gross Inventory (202143) + Total Supply (202144) - Total demand (202144)

goyalsa_0-1634611514239.png

 

Total Supply Measure: 

_Total Supply measure = [_Available Inventory(NEW)]+[_Cleaning WIP]+[_Demurrage WIP]+[_Repo WIP]+[_Order WIP]-[_Repair WIP]
 
Total Demand measure
_Gross demand = [_Forecasted demand measure]-[_Forecasted/Allocated]+[_Not Forecasted/Not Allocated]+[_Repo out(manually)]
 
Gross Inventory  measure
_Gross Inventory = CALCULATE([_Total Supply measure]-[_Gross demand], FILTER(ALLSELECTED(Dates),Dates[Loadingweek] <= MAX(Dates[Loadingweek])))

 

Hope this will helps.

 

Kind regards,

Sahil

@goyalsa It's very difficult to reference the same measure within itself in DAX, but you could do the total supply up to current week - total supply up to next week. 

 

In your Gross Inventory you're applying the same dates to both supply and demand. You need to filter them separately: 

 

_Gross Inventory = 

CALCULATE [_Total Supply measure],

FILTER(ALLSELECTED(Dates), Dates[Loadingweek] <= MAX(Dates[Loadingweek]) ) )

-CALCULATE ( [_Gross demand], FILTER(ALLSELECTED(Dates), Dates[Loadingweek] <= MAX(Dates[Loadingweek]) +1 ) )


Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy ,

It is giving a visual error.

I created a date table and link the Supply & demand table with the loading week in the date table.

goyalsa_0-1634619205983.png

Kind regards,

Sahil

@goyalsa  What does it say when you click 'See details' please?


Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors