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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
goyalsa
Helper III
Helper III

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.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

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.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

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.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.