Previous Month Calculation without Date Filters or Attributes in Report - date

I am trying to create a report that shows total sales for the previous financial year (March-April), the current financial ytd, and the previous month in powerbi. I do not want to include any date attributes in the report or place any date filters on the report.
The 2 measures below are working as expected, but I am running into issues when trying to calculate for the previous month.
This Year = CALCULATE('Fact InvoiceLine'[Total Fare Currency],
DATESYTD(ENDOFYEAR(dateadd('Date'[Date], -2,Year),"3/31"),"3/31"))
Previous Year = CALCULATE('Fact InvoiceLine'[Total Fare Currency],
DATESYTD(ENDOFYEAR(dateadd('Date'[Date], -3,Year),"3/31"),"3/31"))
The closest I have been able to get, though it's still far from what I need.... is this,
Last Month = CALCULATE('Fact InvoiceLine'[Total Fare Currency],
DATESMTD(ENDOFMONTH(dateadd('Date'[Date], -2,YEAR))))
which goes back 11 calendar months, but what I need is to see the total for 1 calendar month. Using PREVIOUSMONTH does not work either, as that requires either a date filter or date value in the report.

Last Month =
CALCULATE([Total Fare Currency],
FILTER(ALL('Date'),'Date'[Date] >= EOMONTH(TODAY(),-2)+1),
FILTER(ALL('Date'),'Date'[Date] <= EOMONTH(TODAY(),-1))
)

Related

Tableau Fixed Max date registered by month

I want to create a graph line in tableau with a count distinct id per month.
I use an excel spreadsheet that is updated a few times per month but never on the same date, so I have different dates registered as months go by.
I want to use the last date registered per month so I can use that date to show month's trend through the years. Each id represent a different construction building, so it is expected that the same id can be found on different months.
This is what I tried: Tableau Fixed (LOD) formula the get last date registered per each month:
{ FIXED [id_constructionbuilding], MONTH([date_registered]): MAX([date_registered])}
Then I use rows and columns in tableau but I get more than one max date (my excel has 2020 and 2021 dates, so it's picking dates from October 2020 and October 2021 for example). Dates are order according to Spanish so you will see month and days shifted:
I would suggest updating your calculated field to:
{ FIXED [id_constructionbuilding],DATETRUNC('month', [date_registered]), DATETRUNC('year', [date_registered]):MAX([date_registered])}
This will keep the level of detail (LOD) to the id_constru..., month and year.

Tableau, Week to Date, Month To Date, Year to Date parameter

I have a data set spanning 2 years and is updated daily, created a dashboard to give a view of incidents by date group. I have created a parameter using date trunc for Day/Week/Month/Quarter/Year. This is in Tableau.
I am trying to get the parameter to show a Week to date, Month to date and so on view. IE if on Weds 15th Dec I selected the weekly view, it would only show data for every week in the data set for Sat-Weds (My weeks go Sat-Fri) or the monthly view every month between 1st-15th
Ideally I am wanting this as a simple parameter for a drop down menu, I can do the week to date stuff as a rolling sum restarting every week in a separate table, but for ease I just need a date group function that will allow to do this.
Any suggestions would be appreciated.
Cheers
Pete
The solution is 5 parts:
Date Part Parameter
Max date [Max Date]
Dynamic date part of the Max date [Dynamic Date Part Max]
Dynamic date part of the historical dates [Dynamic Date Part]
Filter those date parts <= the Max date [Dynamic Date - Lass than Max]
Date Part Parameter
Max Date
This is the calculation you'd use with your dataset to find the max date.
{ MAX([Order Date]) }
In order to create a good example, I'm going to set my Max date to a specific date the falls in the middle of a week, in the middle of a month and middle of the year. I'm going use June 13th, 2018 as my Max Date.
So, if you want to follow along you can use the below date as your max date. You can also use this data set if you'd like.
DATE(#2018-06-13#)
Dynamic date part of the Max date
DATEPART([Select Date Part], [Max Date])
Dynamic date part of the Historical dates
DATEPART([Select Date Part], [Order Date])
Filter on Historical dates parts <= the Max Date
[Dynamic Date Part] <= [Dynamic Date Part Max]
Now that we have all the pieces we need let's check to make sure they are working as we would expect.
Looks like we're seeing all the days of the month that are <= the 13th.
When we change it to Day of the Week we see only the days of the week <= the 4th day of the week which is Wednesday when the week starts on Saturday.
Now let's calculate the running sum of sales along our dynamic date part to better help you with your example.
Drag the measure you want to calculate the running sum onto the label, then create a quick table calculation. We'll next need to edit this table calculation as so.
You'll then see your calculation working as you would expect.
Hope this was helpful. Happy vizzing!

Filter SSRS subreport for 12 months from first day of month to last day of month

I have a SSRS report that has typical Start Date / End Date parameters that will filter out Sales Order information based on the OrderDate field. With this report, I have a subreport. This subrebort is basically nothing more than an aggregation of the same info, by month. This aggregate information should be from the first day of the month, one year prior, through the last day of the End Date's parameters month. This does not take the main subreports Start Date parameter into consideration at all.
This is where it gets a little tricky. For example, lets say I made the start date / end date parameters on my main report:
10/15/2016 - 11/15/2016
(just remember, for this purpose, the start date is irrelevant)
I would want the subreport to show the sales totals, per month, for the ENTIRE month of December 2015 through the ENTIRE month of November 2016, even though my end date was 11/15/2016.
If I were to put in those same dates for my parameters in the report right now, for the aggregation of December 2015, I would only get sales from the 15th through the 31st. Currently I have my subreport to filter on the OrderDate by:
Fields!OrderDate.Value>= DateAdd(DateInterval.Month, -12,Parameters!EndDate.Value)
I know that this filter is not currently set up to have an end date for the parameter, just a greater than argument, which is wrong since I want the 12 month history to stop at the last day of the month for the month of my End Date parameter, but I don't know how to make that happen either.
I hope I have explained this well. Any help on this would be greatly appreciated.
You can set a filter to get only dates between a specific range in your subreport dataset, tablix and some visualizations:
In DataSet properties or Tablix Properties in the Filter tab use these settings:
In the Value textboxes you should use the expressions to calculate your date range.
StartDate
=DateSerial(Parameters!EndDate.Value.Year-1,Parameters!EndDate.Value.Month,1).AddMonths(1)
EndDate
=DateSerial(
Parameters!EndDate.Value.Year,Parameters!EndDate.Value.Month,1).AddMonths(1).AddDays(-1)
It should filter your data from 12/01/2015 to 11/30/2016 if your EndDate parameter is set to 11/15/2016
Let me know if this helps.

Creating Dynamic Date Column Headings in Cross Tab for Business Objects

BO Version: 12.1.0 on Infoview,
O/S: W7
I am creating a report in infoview, which is a cross-tab. I have departments on the row side and for the column I want to have all Saturday dates dynamically displayed, and this is dependent on the date prompt values I put in to the report when I run it.
So if I put in for the prompts Dec the 08th 2013 to Jan the 04th 2014 I should see 4 Saturday dates (14th/21st/28th/04th) along the column headers.
I started off using a variable and using the function relativedate, which gave me all the dates I wanted:
=RelativeDate(LastDayOfWeek([Query 1].[Episode End Date]);-1)
but because I used -1 to get the Saturday date it was giving me the Saturday before the earliest prompt date, so I was getting these dates instead:
(07th/14th/21st/28th/04th)
Is there a way I can get these dates but ignore the previous day (the 7th) before the start prompt date?
I want to have this dynamic so that if I put a date range in it shows me all the saturday dates within that range along the top of the report regardless of the date range period.
Andrew
The reason you're having trouble is that WebI (being ISO compliant) considers a week to run from Monday to Sunday, but your reporting week ends on Saturday.
So, I would approach it this way:
=RelativeDate(
LastDayOfWeek(
RelativeDate([Query 1].[Episode End Date];1)
)
;-1)
If we evaluate some dates with this logic, we'll see the desired result:
Testing 12/8 (Sunday):
Add one day = 12/9
Get Last Day Of Week = 12/15
Subtract one day = 12/14
Testing 12/12 (Thursday)
Add one day = 12/13
Get Last Day Of Week = 12/15
Subtract one day = 12/14
Testing 12/14 (Saturday)
Add one day = 12/15
Get Last Day Of Week = 12/15
Subtract one day = 12/14
I'm at home and don't have access to WebI right now, so I can't test this myself, but the logic should be sound.

Get month from date parameter in MDX

I'm currently building reports using Reporting Services (and MDX language).
I get a date thanks to a parameter:
MEMBER [Measures].[retail sales amount] AS (
STRTOMEMBER(#TimecalendarTimecalendarmonthhierarchy)
, [Measures].[Retail sales amount invoiced including tax])
STRTOMEMBER(#TimecalendarTimecalendarmonthhierarchy) could be something like that [Time calendar].[Time calendar month hierarchy].[Time calendar date].&[2011-03-18T00:00:00]
I would like to only get the month of this parameter. When I use:
MTD([Time calendar].[Time calendar month hierarchy].[Time calendar date].&[2011-03-18T00:00:00]
, [Measures].[Retail sales amount invoiced including tax])
it works fine but that's not the case for
MTD(STRTOMEMBER(#TimecalendarTimecalendarmonthhierarchy)
, [Measures].[Retail sales amount invoiced including tax])
Try :
MTD( STRTOMEMBER(#TimecalendarTimecalendarmonthhierarchy) ) * {[Measures].[Retail sales amount invoiced including tax]}
If it does not work, what is the result of :
STRTOMEMBER(#TimecalendarTimecalendarmonthhierarchy).name
MTD will give you the set of dates from the first date of the month to the date specified. If you want to get the month, you can either use ANCESTOR or PARENT. Parent will work if Month is directly above Date in your hierarchy. The difference between SUM(MTD(date), measure) and (date.parent, measure) is obvious when you think about previous months - if you go to a month which is in the past MTD will give you partial results as opposed to the month member itself (for dates other than the last date of the month).
StrToMember essentially translates a string to a member expression in MDX. There is no difference (functionally) between writing:
([Time].[Month].&[201001], [Measures].[SomeMeasure])
and
(StrToMember("[Time].[Month].&[201001]"), [Measures].[SomeMeasure])
It would be interesting to hear what exactly the error is when you execute your non-working expression in order to debug.
If you just want to get the month amount for the measure, you should write:
(StrToMember(#param).Parent, [Measures].[Retail sales amount...])
or (if you have more levels in between):
(Ancestor(StrToMember(#param),
[Time calendar].[<hierarchy>].[<month level>]),
[Measures].[Retail sales amount...])
Also, when using MTD you want to write:
SUM(MTD(<date member>), [Measure].[Some Measure])
instead of
MTD(<date member>, [Measure].[Some Measure])
have a look at BOL's definition of MTD