I am trying to find a way to display the rolling 12 month sum of the last 12 months. My table is called CV_Spend__R2:
Year and Month come from a date hierarchy from the same table while Profit is a calculated measure (SUM) of that particular implicit measure. R12 is the rolling sum of the last 12 months contained in the dataset:
R12 = CALCULATE(SUM(CV_SPEND_R2[Profit]),
DATESBETWEEN(CV_SPEND_R2[EOM].[Date],
NEXTDAY(SAMEPERIODLASTYEAR(LASTDATE(CV_SPEND_R2[EOM].[Date]))),
LASTDATE(CV_SPEND_R2[EOM].[Date])))
So far so good. Now the measure TTM should show me the same value as R12 but only for the last 12 months from a month/year date that I select. For this I created a separate date table with no relationship with the model:
DATE = CALENDAR(MIN(CV_SPEND_R2[EOM].[Date]), MAX(CV_SPEND_R2[EOM].[Date]))
For example, I want the TTM to show only the R12 values for March 2019 to March 2020 if March 2020 is selected as in the end R12 needs to be removed from the table.
I somehow managed to make this dynamic, but it is not working correctly and I am at wits' end. This is what I came up with:
TTM =
VAR CurrentDate = MAX('DATE'[Date])
VAR PreviousDate = DATE(YEAR(CurrentDate), MONTH(CurrentDate)-12, DAY(CurrentDate))
VAR Result1 = CALCULATE([R12], FILTER(CV_SPEND_R2,CV_SPEND_R2[EOM] >= PreviousDate && CV_SPEND_R2[EOM] <= CurrentDate))
The problem with this is that it displays the correct months dynamically, but then it breaks down the the R12 value into the twelve months it contains in the interval, basically rolling back my efforts. If I add the TTM value on a card it shows the correct value for that month. I have tried other options with DATESINPERIOD, DATESYTD and DATESBETWEEN, but they either aren't dynamic to show only the last 12 months based on my selection, or they don't show the desired values.
I have also tried:
TTM =
VAR CurrentDate = MAX('DATE'[Date])
VAR PreviousDate = DATE(YEAR(CurrentDate), MONTH(CurrentDate)-12, DAY(CurrentDate))
VAR Result5 = IF(MAX(CV_SPEND_R2[EOM].[Date])<=CurrentDate && MIN(CV_SPEND_R2[EOM].[Date])>= PreviousDate,[R12])
The problem with this is that when I try to display it in a stacked column chart with TTM and [EOM] on the axis, nothing is displayed because it does not accept TTM in the chart, and the chart is my ultimate goal.
Can you please assist me with a solution for this? How to display only 12 months of rolling 12 months' sum from a selection? Please mind that in this example the March 2019 value also needs to be the sum of its previous 12 months, because I already found a solution to start the rolling 12-months sum in the dynamic interval (i.e. March 2019 = 1.028 bn), but this is not what I need. I want to see the R12 value for the 12 months in the TTM column so that I can display it in a stacked column chart later.
Thanks a lot.
After a quick look at your measures, it looks like you only need to slightly modify one. Replace table name in FILTER to ALL(CV_SPEND_R2)
TTM =
VAR CurrentDate = MAX('DATE'[Date])
VAR PreviousDate = DATE(YEAR(CurrentDate), MONTH(CurrentDate)-12, DAY(CurrentDate))
VAR Result1 = CALCULATE([R12], FILTER(ALL(CV_SPEND_R2),CV_SPEND_R2[EOM] >= PreviousDate && CV_SPEND_R2[EOM] <= CurrentDate))
Related
I can calculate the yearly averages, max and min values based on taking the first day of a year as January First like:
yearly_avg=df2.groupby(years).mean()
yearly_sum=df2.groupby(years).sum()
yearly_MAX=df2.groupby(years).max()
yearly_MIN=df2.groupby(years).min()
I need to calculate averages, max and min numbers based on the water year where October 1st is the first day of a year. As an explanation of "water year": https://en.wikipedia.org/wiki/Water_year
Here is my sample file stored here:
https://drive.google.com/file/d/1AYi9vp3_DPXHoCPB_YkMQp68FvC_INrV/view?usp=sharing
How can I do that?
Thanks.
Just set the year to start on October instead of January. I am just happy your columns were already datetime types, this made it easier!
df = pd.read_excel('sample_water_year.xlsx')
df['# YEAR'] = df.Dates.dt.to_period('A-Sep') #year ends on sep
Note that you will have to subtract 1 as it does not change the initial year value set.
df['# YEAR'] = df['# YEAR'] - 1
Then simply find the summary statistics:
yearly_avg = df.groupby('# YEAR').mean()
yearly_sum = df.groupby('# YEAR').sum()
yearly_MAX = df.groupby('# YEAR').max()
yearly_MIN = df.groupby('# YEAR').min()
Hopefully this helps!
I have dimension as date, --(Date has discrete dates- some dates from this months , some dates from last and so on - with data.)
more dimensions are : Team name & Team ID
other dimension is Result.
Result column has value : pass or fail ---only two values.
below data gets refreshed everyday.
date Team name Team ID Result
24/07/2008 lol 458 pass
27/01/2017 pop 1478 fail
28/02/2018 laugh 99 pass
and so on
I want to show dates on x axis, Result : Pass or Fail on trend-lines .
what would be my Y axis?
Want to show pass or fail team ID wise on trend lines!
If its December month then team ID which have passed /failed for 31st of December 2017 should show up.
similarly for Jan month (team ID ) which have passed or failed should show of 31st jan 2018.
AND for Feb month it should show pass / fail for current date --- {Team count pass or fail for particular current day}
please help with calculated filed calculations
Try This:
if Date= today() then 1
elseif dateadd('day',-
day(DATEADD('month',1,Date)),DATEADD('month',1,Date))=Date then 1
else 0
than set filter to 1
I have a scenario.
In the sample table below, I need to show the sales by year…
And for each year, I need to show the last yr and last 2nd year sales for that year.
For example in 2014,
Current Year = 2014 Sales
Last Year = 2013 Sales
Current Year = 2013 Sales
Last Year = 2012 Sales
|----------2013------------|---------2014-------------|
| Last Year | Current Year | Last Year | Current Year |
Ive tried but when i nest them under a year dimension.. the calculations are not working.. is there a way around this, to come up with this kind of report format? our user is very particular in having such format..
many thanks for the help.
I'd simply hardcode all rows, and skip the year dimension:
Current Year
Sum({< Date = {">=$(=YearStart(min(Date),0"}*{">=$(=Addyears(max(Date),0)"} >} SalesAmount)
Last Year:
Sum({< Date = {">=$(=YearStart(min(Date),-1"}*{">=$(=Addyears(max(Date),-1)"} >} SalesAmount)
-2 Year:
Sum({< Date = {">=$(=YearStart(min(Date),-2"}*{">=$(=Addyears(max(Date),-2)"} >} SalesAmount)
I think this could be achieved using a pivot table. Here's an example.
You can solve this problem at the script side while loading data. So that you can compare year to date data with previous year with until corresponding month.
Transaction_Table:
LOAD date,productID,amount
FROM data.qvd;
concatenate
Load AddYears(date,1) as date,productID,amount_1
from data.qvd where date<=AddYears($(=max(date)),-1);
Data_Table:
load distinct
date,
month(date) as Month,
year(date) as Year
resident Transaction_Table;
There will be two coloumns "amount" is current date's data and "amount_1" is previous year's same day data.
Create pivot chart put year to top and product to left and create two expressions. One for calculation of amount_1: previous term and one for amount: current term
You can name expressions:
previous year label: =year-1
current year label: =year
How do I display the following info in SSRS?
The formula in the cell in Column H is "=IFERROR(F3/D3-1, 0)".
I don't know how it is done technically. But something like
((Revenue where Year = FY14 and Condition = Y)/(Revenue where Year = FY13 and Condition = U)) -1
Aim is to show the Year On Year growth. Thank you.
I am novice with SSRS.
I have a report which should display 60 months (5 years displayed like Jan 1999, feb 1999 & so on till the end of 60 months) and its corresponding sales amount. I want to get averages for the first 12 months (i.e for the 1st year) and so on. Is it possible? My dataset just gives me all the 60 months row-by-row.I am using matrix for my report.
Thanks,
User007.
I would add some nested row grouping to the matrix. The higher-level group would be by year, which would allow you to have a row in the matrix that totals/averages all of the data for the year. The inner group would be by month, giving you the individual month rows as your dataset returns them.
Here is some information about defining and using groups