Forum Discussion
Transaction level date to Rolling Time Summary
- Anonymous8 years ago
Hmm, not sure if you want to get the following results.
If it is, first create a calcuated column and use the following DAX to add Rank Number
Rank = RANKX(Sold,Sold[Date],,ASC,Dense)
Then, create another calucated column and use the DAX below to get the cumulative sum in 2 days by item name
2Days_Sum = CALCULATE(SUM(Sold[Sold]),ALLEXCEPT(Sold,Sold[Item Name]),Sold[Rank]<=EARLIER(Sold[Rank])&&Sold[Rank]>EARLIER(Sold[Rank])-2)
Not sure if you want to get the following results.
Say you have a table like this
Create a measure with the following DAX, it can give you the latest 10 days total sold counting for the max date value in the table
latest4Days = SUMX(FILTER(Sold,Sold[Date]<=MAX(Sold[Date])&&Sold[Date]>MAX(Sold[Date])-4),Sold[Sold])
If you want to get the last 4 days total sold counting from today, you can try the following DAX
Last4Days = SUMX(FILTER(Sold,Sold[Date]<=TODAY()&&Sold[Date]>TODAY()-4),Sold[Sold])
I apologize, I did a poor job explaining my question in that first post.
I want the sum to be 4 days from the rows date value.
So if my data covered the month of July. This particular rows date is 7-12-2018, I would want to sum all of the values from 7-8-2018 through 7-12-2018.
I would anticipate the values to change for every row since its a rolling sum of the previous 4 days. Since the test dataset that I am trying to use for this logic is self generated, I was keeping it small and trying to do it on two days.
2daysum = SUMX(FILTER(Sheet1,Sheet1[DATE] >= Sheet1[Date]-2 && Sheet1[Date]<=Sheet1[Date]),Sheet1[Sold])
But all I am getting is the same value for every row.