Forum Discussion
Closing Balance Inventory Prior Year
Hi All,
I am stuck on the following...
I am trying to create the Closing Balance Inventory for 2020 e compare with the same period last year..
Hi Anonymous
Does this return what you want?
Inventory Last Year = CALCULATE( [Inv. Sum], SAMEPERIODLASTYEAR( 'Calendar'[Date] ) )ALso, you need to mark your calendar table as a date table. That is when the magic happens. Right-click on it, select Mark as Date Table, then select the date column. Until you do that, it is just another table in the model.
9 Replies
- edhansCommunity Champion
Hi Anonymous
Does this return what you want?
Inventory Last Year = CALCULATE( [Inv. Sum], SAMEPERIODLASTYEAR( 'Calendar'[Date] ) )ALso, you need to mark your calendar table as a date table. That is when the magic happens. Right-click on it, select Mark as Date Table, then select the date column. Until you do that, it is just another table in the model.
- AnonymousNot applicable
thanks a lot for the answer. I need to use the closingbalancequarter..
1. I marked the table as date
but it still giving me a error...
- edhansCommunity Champion
I'm not an expert by any means on the CLOSINGBALANCE* functions, but I believe those return the data at the end of the relevant quarter, which would be March 31, June 30, Sept 30, and Dec 31. That works on your Calendar table.
But those dates don't exist in your inventory table. Everything is the 1st of the month.
My measure above returns the following:
See this article near the bottom from SQLBI. It concludes the same thing I have. Emphasis mine.
"The STARTOFMONTH, STARTOFQUARTER, STARTOFYEAR, ENDOFMONTH, ENDOFQUARTER, and ENDOFYEAR functions are only useful when the dataset is complete with all the start and end dates of each time period. When this is not the case, you can implement a custom logic using the other techniques previously described in this article."
- AnonymousNot applicable
man.. after 4 hours on this **bleep** formula... I got it!!!! thanks for the help. really killed me!!! appreciate!
- edhansCommunity Champion
Anonymous wrote:
man.. after 4 hours on this **bleep** formula... I got it!!!! thanks for the help. really killed me!!! appreciate!
What was your final measure?
- parry2kSuper User
Anonymous do you have date dimension in your model? As a best practice, add date dimension in your model and use it for and time intelligence calculations. There are many posts on how to add date dimension and below is the link to a few. Once the date dimension is added, mark it as a date table on table tools.
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columnsIf not, add one, and use that in your calculations.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
- AnonymousNot applicable
Thanks, I have tried already, but it doesn't work
- AnonymousNot applicable
hi, I have added the link to power BI, in case you want to have a look. thanks Simone