Forum Discussion
Last Week value from YTD Measure
Hi,
I have below a measure to calculate year to date inventory value.
*X - axis is a Year & Week Number
Currently, I need to determine which materials or products changed in a particular week.
Is this possible to get this value by modifying the above measure?
Or is any way to get this done?
6 Replies
- Greg_DecklerCommunity Champion
pawelj795 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.- pawelj795Post Prodigy
Hi Greg_Deckler, thanks for weighing in.
Could you specify which part you don't understand?
Sample data will be a lot of work to do, because it's a quite complicated report.
I only want to calculate the previous week value from the mentioned measure.- Greg_DecklerCommunity Champion
pawelj795 It's also a lot of work to answer questions. Especially when there isn't sample data so you can't just mock it up and solve it but have to kind of recreate the data model in your head by parsing someone else's code.
Do you have a week number column? Is it sequential year over year? There are a bunch of unknowns. You can use WEEKNUM to find the current week and then -1 for the previous week. Have to account for the 1st of the year though.
- amitchandakSuper User
pawelj795 , you can get a week start and week end value and based on that you can limit till last week end
Use with date table
YTD Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Number]<=max('Date'[Week Number]) && 'Date'[Week Year]= max('Date'[Week Year])))
YTD Week a week before = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Number]<=max('Date'[Week Number]) -1 && 'Date'[Week Year]= max('Date'[Week Year])))
LYD Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Number]=max('Date'[Week Number]) && 'Date'[Week Year]= max('Date'[Week Year])-1 ))https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123- pawelj795Post Prodigy
amitchandak
Greg_Deckler
Below is my sample data, I hope it will help.
https://drive.google.com/file/d/1uBTV8b8icDXyjZ2Jm2VmBXnv_8HdlLGc/view?usp=sharing
I was trying to create the desired measure by myself, but it is not calculating correctly.- amitchandakSuper User