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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous2024_
Regular Visitor

How to refer to a previous value in a measure

I have an availble stock for the current week. I want to calculate the +inbound and -outbound of the week to have current stock. This dynmacilly created current stock should be used as reference for the next week calculation [start of stock]. then again +inbound -outbound  
inbound and outbound are measures which have been created in severeal measures, no columns in a table. So, index is not possible here. 

How can I move the current stock week by week ? I would appreciate if you could help. 

Anonymous2024__0-1715341856959.png

 

5 REPLIES 5
AnushaSri
Advocate II
Advocate II

Hi,

You might create the following DAX to get the date of Previous week end date (Considering Monday as start of week and Sunday as Weekend).

PreviousWeekEnd = MAX(DimDate[Date])-WEEKDAY(MAX(DimDate[Date]), 2)

You can use the date value generated by the above Dax to filter current stock to look at the end of previous week. it would be some thing like this.

Calculate(CurrentStock, Date=PreviousWeekend)

Please accept this as solution and give Kudos if it helps to resolve your issue.

Hi AnushaSri, 

 

thank you for the reply. 

I tried your suggestion but receive the following error

Anonymous2024__0-1715349669295.png

 

create Previousweekend as a variable in your start of stock2 measure and then use it in calculate
Start of Stock2 =


Var x= MAX('DimDate.1'[Date])-WEEKDAY(MAX('DimDate.1'[Date]), 2)

Return CALCULATE([Total Questions], 'DimDate.1'[Date]=x)

I have tried so many options but still no result, I can't figure it how to make it dynamically 😞 

Anonymous2024__0-1715842172028.png

Is there anyone who can support, plesae 

I still have the wrong numbers. 

Anonymous2024__0-1715789355943.png

For the current week, everything works fine. I can take the results and bring it to next week as a starting point. But from there my "Current Stock" dosn't calculate right. 

Current Stock =
var currentDate = TODAY()
var CurrentDeliveries = [Current Week Stock]  //  [available stock]+ in - out 
var CurrentForecast = [Next week Stock]         // [start of stock] + in - out 

return
IF(MIN('Date'[Date])<currentDate,CurrentDeliveries,CurrentForecast)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors