I am new with Datazen and trying some comparison options. Is it possible to compare values with that of one year before? All the data is available, so it seems unnecessary to copy the whole datatable and deduct one year of the date.
It is possible. However the calculation needs to be done in your SQL/MDX.
So you will need to have a "this year" measure/value and a corresponding "last year" measure/value.
Simply having all the data that you need in a dataset will not solve your problem as you can't do any sort of custom calculations in Datazen.
Below an example with MDX. In date field select the date that you want to compare with the parallel 1 year ago.
SELECT
{[Measures].[Internet Order Quantity]} ON 0
, {[Date].[Calendar].[Date].[March 22, 2004]
, ParallelPeriod([Date].[Calendar].[Calendar Year]
, 1
, [Date].[Calendar].[Date].[March 22, 2004]
)
} ON 1
FROM [Adventure Works]
If you want to compare two or more years in the same time chart I've hacked a solution for this earlier. I've made a column in my MDX that pulls out the year so I can use this as the series name column. Then if my data f.ex is monthly I've updated all the months to point to the same year. Meaning I have a column with three values for 1/1/2015, but in my series name column I have 2013, 2014 and 2015 so I can chart something like this.
It is a hack, but I've found it to be useful in some occasions.
Thank you for your answers. I solved it myself by making a new view with
DATEADD (year,1,usedDate)
Comparing these two views gives the right solution too.
Related
I have the following table in SQL:
Start - End - Amount **per day**
06.07.2020 10.07.2020 10
08.07.2020 08.07.2020 5
08.07.2020 15.07.2020 20
02.07.2020 06.07.2020 3
Now I want to filter this table by the calendar week. Let's say "where [calendar week] = cw28". cw28 is from the 06th of july to the 12th of july.
With that I'd like to have the sum of the amount of the days that lie between those two dates. One single number.
I'm using MS SQL Server (SQL Express).
I can't figure out how to distinguish (and break down) if one day lays between the two date values or not. And if yes how much I need to sum up.
I tried to make a picture in excel to create a logic from this:
"Logic" in Excel
Can anyone help me with this? :)
Thx and Best!,
Max
Not sure about your exact requirement. But below is the query to get the sum of values between two dates.
select sum(amount_of_days) from table where date_column between '06-JUL-2020' and '07-JUL-2010';
Change the column name and table name according to your requirement
I'm currently struggling with how to produce a Fiscal Year parameter, so its values start with Current year, but also contain records from all previous years, and then have all following values be each following year.
So the Fiscal Year would look roughly like the following
Current (I would want to include all previous Fiscal years in this as well),
F18,
F19,
F20,
etc. etc.
As of right now, I have all fiscal years on the drop down, starting with the earliest fiscal year that exists in the database using the following query to populate the parameter dropdown.
SELECT DISTINCT FiscalConsideration FROM dbo.Currency
Which would look like this
F12,
F14,
F15,
F16,
F17,
F18,
etc. etc.
Then I filter the results based on the selected Fiscal year.
Question 1
Is there a way where I might be able to do this, have all records from current fiscal year and prior on one value and all individual fiscal years after?
Question 2
I have also discovered that I can't have this be multi-select AND accept NULL's as well. Might I be able to convert nulls to a custom string or something and have that be an option as well?
I ended up doing it by incorporating more of the logic I wanted into the computed column in SQL Server Management Studio with another case when for past records, and changing nulls with isnull to 'TBD'
EDIT: As this is an old question, the intended solution is supported by the relative date slicer in Power BI as seen here.
I am building a rolling 13 month net revenue chart and I've came across a requirement to show the last 13 month in x axis based in what month (YYYYMM) the user selected in a YYYYMM slicer.
The chart below is the one I want:
In order to get the intended behaviour, currently I need to select each one of the 13 month in YYYYMM slicer:
Any ideas on how I can get this to work in Power BI so that the user just have to select the base month?
Thanks in advance,
Cristhian.
Let's say you have a table data(date, value).
Add a table datefilter(date) with dates you want to select. Add a slicer by this date.
Add a calculated column to data : date2 = DATEADD('data'[date].[Date],13,MONTH)
Add this measure:
current = IF(AND(
MAX('data'[date]) < MAX('datefilter'[date]),
MAX('data'[date2]) > MAX('datefilter'[date])),1,0)
filter your visualisation by current is 1.
I've created a new measure which uses [TotalSales] and 'SAMEPERIODLASTYEAR' to calculate the previous year's sales, see below:
=CALCULATE([TotalSales], SAMEPERIODLASTYEAR(Dates[Date]))
This all works fine if I create a pivot that displays individual dates (e.g. 01/01/2015) and then the new measure 'previous year sales' value next to it. My problem occurs when I want to change the pivot and display previous year sales by year, quarter or month - with any of these options I get no sales value.
I'm using a 'Dates' table which is linked to the Sales table.
Am I right in thinking I can re-aggregate sales in this way? I have seen an error message which says something about not been able to aggregate a non-contiguous value or date.
I've had a good look to see if anyone else has experienced the same problem, but can't see anything. Any guidance would be helpful.
Regards,
Martyn
Yes you can re-aggregate in this way. Your formula is correct would handles the changes to the aggregation level.
I would check that your 'Dates' table is marked as a date table. Ensure that the year, quarter & months are in this date table and not in your Sales table. Make sure that your date table has one record for each day between the beginning of your sales data set and the end. Check behavior in Power View if you are using Excel 2013.
I'm building a report in Reporting Services 2005 based on a SSAS 2005 cube. The basic idea of the report is that they want to see sales for this fiscal year to date vs. last year sales year to date. It sounds simple, but being that this is my first "real" report based on SSAS, I'm having a hell of a time.
First, how would one calculate the current fiscal year, quarter, or month. I have a Fiscal Date Hierarchy with all that information in it, but I can't figure out how to say: "Based on today's date, find the current fiscal year, quarter, and month."
My second, but slightly smaller problem, is getting last years sales vs. this years sales. I have seen MANY examples on how to do this, but they all assume that you select the date manually. Since this is a report and will run pretty much on it's own, I need a way to insert the "current" fiscal year, quarter, and month into the PERIODSTODATE or PARALLELPERIOD functions to get what I want.
So, I'm begging for your help on this one.
You'll probably need to modify the SSRS MDX by hand to do this. It is possible to get SSAS to use "Today", it is usually done as something like this:
WITH
MEMBER [Today]
AS {
StrToMember("[Date].[Date Key].&[" + Format(now(), "yyyyMMdd") + "]")
}
SELECT
[Measures].[Some Measure]
ON COLUMNS
FROM
[Cube]
WHERE
{[Today]}
You'll need to change that to fit your own cube structure of course.
So, given that you have fiscal year, and you want to plug values in, modify the above to fit? Put together a string like I showed you that equates to the values you want to use. It sounds like you're OK after that?
You should be able to figure this out using various functions which can tell you 'where you are in the hierarchy'
e.g.
http://www.sqldev.org/sql-server-analysis-services/find-parent-of-current-day-10080.shtml
I know it is a "bit" too late but for people reaching this question page this might help:
IIF(Month(Now()) > MonthOffSetNumber, Year(Now()) + 1,Year(Now()))
This is for getting the current fiscal year. This will be applied in something like this:
SET CurrentFiscalYear AS
(
StrToSet("[Dim Date Name].[Fiscal Year].&[" + Format(IIF(Month(Now()) > MonthOffSetNumber, Year(Now()) + 1,Year(Now()))) + "]")
)
This will help for later cross join in the query.
WE find an easy way to calaculate fiscal period to date date in mdx by using parameters. Imagine that we have BeginDate (01/04/2014) and EndDate (31/03/2015). Here are the formulars. Click on Parameter "beginDate" in Report Data - right click parameters - Specify values - add expression value:
=DATEADD
("M"
,IIF(Month(Today())<4
,-Month(Today())-8
,-Month(Today())+4
)
,DATEADD("D",0-DATEPART("D",Today())+1,Today()))
Do the same for the second parameter "EndDate" and set the Defualt values - Specify values and add expression value:
=DATEADD("D",-1,DATEADD("M",12,DATEADD
("M"
,IIF(Month(Today())<4
,-Month(Today())-8
,-Month(Today())+4
)
,DATEADD("D",0-DATEPART("D",Today())+1,Today()))))
Now your ssrs report will have the fiscal period as default period.
Moise Kabongo