Matrix colum headers in Monthly order - reporting-services

I'm using a matrix and I would like my Month column headers to be in fiscal order...so April,May,June, July etc
I have looked at various answers about adding a calculated field but this only seemed to work for rows. I'm using Report Builder 3. Would appreciate some help please.

You can use something like:
=iif(datepart(DateInterval.Month, Fields!DateCompleted.Value) < 4, datepart(DateInterval.Month, Fields!DateCompleted.Value) + 12, datepart(DateInterval.Month, Fields!DateCompleted.Value))
This will add 12 to any month before April, making January month 13 and so on. Just use that in your sort order.

Related

SSRS: Dynamic difference between two columns in MATRIX

I try to create (in SSRS) a summary of incomes in years and I'm stuck when I try to compare them.
e.g. of my table, where Rok = Years:
I have table like at image above where A and B are Expressions (sums of incomes). Columns are years from the SQL query, So 2020 will appear soon. I would like to divide 2019 vs 2018 but dynamically so if 2020 will appear, everything will calculate between 2020 and 2019. Do you know any solution for that ? Thanks in advance :)
First you need to have an individual filtered column group for each year.
Second add in column outside group right, labelled as compare and
Insert the following expression: =ReportItems!Rok.value - ReportItems!Rok1.value ( Rok and Rok1 are the Name available from Text Box Properties for each filtered column group)

How can I add titles to columns in a matrix that are created dynamically in a report?

I have a matrix that creates 3 columns when it's run and I am unable to add a title to those dynamically created columns, as required by the client, and can't find any fixes or examples online. I hoped putting the matrix and textboxes into a table might work, but the same result as the images below occurs.
Is this seemingly simple thing just not possible, or is there a workaround I'm missing?
Design View
Result Textbox displayed after columns
Row and Column Groups visible
If you have 3 MTLH1 value for each NTLH2 value then you can do something like this...
(as you supplied no sample data I generated some from the sample WideWorldImporters database). My Query gives me 5 columns and results similar to the below.
CustomerCategoryName Qtr Mnth MnthName OrderValue
Computer Store 1 1 Jan 10
Computer Store 1 2 Feb 12
Computer Store 1 3 Mar 15
Computer Store 2 4 Apr 20
Corporate 1 1 Jan 11
....
Basically we end up with 3 months per quarter
I then added a matrix control to the report, dragged CustomerCategoryName to the rows, Mnth to the Columns , Qtr above Mnth so it becomes a parent column and finally OrderValue to the data "cell".
I actually swapped the Mnth field out for MnthName in the column header to make it easier to read, but the column order is still sorted by Mnth (the numeric version). I then centered the column headers for readability.
The final design looks like this
If we run the report, the result looks like this..
As you can see we have 4 groups, one for each quarter, each with 3 columns.
If you want to customise the quarter names, you could do that if required by changing the expression in the cell. For example if we wanted all quarters to have "Q" preceeding the number except the 2nd Quarter whcih we want to have a specific string then you could use something like.
=IIF(
Fields!Qtr.Value = 2,
"Second Quarter",
"Q" + Cstr(Fields!Qtr.Value)
)
The final output now looks like this...
Alternatively, you could generate all the column headers in t-sql so where I have MnthName you could create a Quartername or similar.
Hopefully this is useful. If not, please post sample data and expected results of that sample data and I'll revise the answer.

Past 5 week calculation in WEBI (BO 4.0)?

I am facing issue in calculating past 5 week data based on current date (excluding currrent week)
For e.g:
Suppose we are in 40th week of this year, I need to get the sum of all the transactions for the previous 5 weeks (39, 38, 37, 36 & 35).
Currently calculating based on the calendar day but as Calendar day is giving the granular level of data, inorder to increase the performance I need to use the calendar week (sample data like (2012/40).
Is there a way to do this?
I'd construct a flag field (either in the back-end or in the universe) using datediff (in SQL Server terms).
Failing that, you could construct a variable in Web Intelligence using the Week function.
Pseudo-code but something like:
=IF(Transaction_Date < Week(CurrentDate()) AND Transaction_Date >= (Week(CurrentDate())-5); "TRUE"; "FALSE")

How to get current month name in SSRS?

I need current month name as default perameter name in my ssrs report. How can I get current month name using an ssrs expression?
For example "27-09-2012" would become "September"
and one more i need....
27-09-2012 to previous month name as well (August)
First question:
=MonthName(Month(Fields!datefield.Value))
Second question:
=MonthName(Month(DateAdd("m", -1, Today())))
I think the second question answer might be something like that, first converting the date to month then subtracting 1 from the month value and then converting it to month name.
Further reading:
SSRS Reports get Month name from Month Index or from date
Converting month number to month name in reporting services
OFF: I would change the date format you are using to 2012-09-27 as it works in every setting and should give you peace of mind when converting date formats.
Don't subtract 1 b/c it won't work for January.
Use this:
MonthName(Month(DateAdd("m", -1, CDate(Today))))
As a note, I tried the suggestion of =MonthName(Month(today())). What I would get is #error for whatever field the expression was in. However, =MonthName(str(Month(today()))) worked for me. I am unsure of whether or not the MonthName method changed to require a string or if it is some issue with my program. Just figured I would post this in case anyone else was having the same issue.
For Previous Month i found universal way : =MonthName(Month(CDate(Today()))-1,False) for SEPTEMBER (Full Month Name) 'OR'
=MonthName(Month(CDate(Today()))-1,True) for SEP (Short Month Name)

Get the week number from a given date

Examples:
'DD/MM/YYYY
"1/1/2009" should give `1`
"31/1/2009" should give `5`
"1/2/2009" should also give `5`
Format("1/2/2009", "ww") returns 6.
So, how can I get the correct result?
It's doing two things here which don't match your expectations, I think:
Assuming you want the week with Jan 1 in as week 1, and using Sunday as first day of the week
So it has week 1 running from Sunday 28th December 2008 to Saturday 3rd Jan 2009.
Week 6 would begin on Sunday 1st Feb by this method.
The ISO standard is for week 1 to be the one containing 4 days of January, or the first Thursday of the year (different ways of expressing the same thing).
You can specify this method of calculation and the first day of the week:
Format(SomeDate,"ww",vbMonday,vbFirstFourDays)
see here for syntax:
https://support.office.com/en-US/article/Format-Function-6F29D87B-8761-408D-81D3-63B9CD842530
Regardless of the day of the week your week starts on, you need to pass unambiguous date values. "31/1/2009" can only be one date (Jan 31st), but "1/2/2009" could be Jan. 2 (US style) or Feb. 1st (everybody else who has more sense that we USAns).
In this case, I'd use DateSerial() to make sure the date is not misinterpreted:
Format(DateSerial(2009,2,1), "ww", vbMonday)
While this is not causing your problem, because Access helpfully utilizes your system's localized date settings, I think it's something you should do anyway. You certainly are forced to do so in SQL in Access, so I don't think it's a bad habit in code and expressions.
This might work: Format(YourDate, "ww",vbMonday)
"Correct result" depends on the locale. Maybe VBA will let you pick a calendar-system, otherwise you're pretty much out of luck.
Note that First-Day-On-xxDay isn't your only problem. There is also variation on what a complete week is so Week 1 in one system could be Week 53 of the previous year in another system.
So test thoroughly and don't be seduced to "correct by 1".
There is a whole standard for week numbers: ISO-8601
http://en.wikipedia.org/wiki/ISO_8601#Week_dates
I had the same problem.
It showed week 53 and week 1, yet days in week 53 and week 1 are all in week 1
I first tried changing the date format in the Access Query to this:
OrderWeek: Format([OrderDate],"yyyy-ww",1,3) <-- But it did not do the trick.
You get dates like 2014-52 for week 52 and 2015-52 where it was week 1 before.
Also the sorting was not how I liked. It sorted the data as 2014-1, 2014-11, 2014-2 etc. I want it to show as 2014-01, 2014-02 .. 2014-11 etc.
So here is the new code to display both the year and the week correctly in an Access Query:
ActualWeek: IIf(DatePart("ww",[SomeDate])=53,DatePart("yyyy",[SomeDate])+1,DatePart("yyyy",[SomeDate])) & "-" & IIf(DatePart("ww",[SomeDate])=53,"01",IIf(DatePart("ww",[SomeDate])<10,"0" & DatePart("ww",[SomeDate]),DatePart("ww",[SomeDate])))
This now shows any days from week 53 as being part of week 1
If sunday is the first day of the week (as it is in some locales) then 6 is the correct weeknumber for "1/2/2009" (february 1. 2009)
In terms of the sorting, I had the same issue and used this code to resolve it:
IIf(Format([SomeDate],"ww")<10,Format([SomeDate],"yyyy-") & "0" & Format([SomeDate],"ww"),Format([SomeDate],"yyyy-ww"))
If the week number is less than 10, add a zero, else leave it as is.
Now the sorting is fine. Hope this helps somebody.