In my report, i show the sales commission for 3 months from each sales person. I've also added the payout month. For a better overall look, i want to add the year to the payout month.
This is the month in my SQL-Query :
,[Monat] = convert(varchar(4),Year(Datum)) + right('00' + convert(varchar(2),Month(Datum)),2)
Right now, the expression for my payout month is this:
=MONTHNAME(IIF(RIGHT(Fields!Monat.Value,2)+2>=13,RIGHT(Fields!Monat.Value,2)-12+2,RIGHT(Fields!Monat.Value,2)+2))
The payout is always two months in the future. Commission of december 2020 will be payed in february 2021, january 2021 will be payed in march 2021 and so on.
I want the result to look like this:
Februar 2021,
März 2021
etc.
Is there a way to depict that in the SSRS expression? Thanks in advance.
If you just need to display the month and year from a date field after you have added 2 months to it, then you can just do something like this.
=DATEADD(DateInterval.Month, 2, Fields!Datum.Value)
You can then format the textbox using MMMM yyyy to display it as you want.
Alternatively, you can do it all in a single step but this should be avoided if possible as you are then losing the date and converting to a string. If you exported to excel for example, you would not be able to do anything with the cell as it would just be a string.
If you really have to do this in all in a single expression then you can use
=FORMAT(DATEADD(DateInterval.Month, 2, Fields!Datum.Value), "MMMM yyyy")
Related
I have an earnings table in my Google Data Studio report from January 21 - YTD.
But what i want is a table that shows me YTM (so this year until last month) Jan-21 til Sep-21 and that dynamicly on 1st Nov, Okt-21 is added to the table, and on 1st dec Nov-21
is added etc.
Because the Total YTD value is other wise too high, due to cost being booked at the end of the month and earnings through the month.
Filters wont let you do it dynamicly,
date range filters same,
always possible to do it manualy with date range but this i cannot ask from my client.
any suggestions??
Kind regards
I found the answer,
i left the question for when someone else wants to do it,
it is actualy simpel fixed by using advanced date filter and then leaving the start date on 1-jan, and end date to today minus 1 month.
this gave me the exact result i needed yt last month
I am building an Alexa skill and using AMAZON.DATE slot type to get a date.
My problem is that when a user says a date without a year, Alexa processes it and returns the date string with a future date.
Example - Today is 2017-09-20, User asks Alexa about date 'Sixth June', Alexa returns 2018-06-06.
I want to use the closest past date instead of closest future dates, for the case when the user doesn't specify a year in the utterance. If the user specifies a year, I don't want to change the date year.
I can't handle this on AWS Lambda using Python, as Alexa sends the complete date string, no matter if the user provides the year or not, in the JSON body.
I don't know if it is even possible to handle such user inputs with Alexa. Is there something I can do about the AMAZON.DATE slot or some other way to handle such user utterances?
You cannot do that with built-in date slot,
Utterances that map to a specific date (such as “today”, or “november twenty-fifth”) convert to a complete date: 2015-11-25. Note that this defaults to dates on or after the current date.
Source :- https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#date
one logic you can try it out is to do a custom logic. Take the difference between todays date and next year same date of user input. If the difference of months between those is greater than 6 months then the nearest would be future date. If difference is less that 6 months then past date. Say user gives an input July 25th (on 2017 ) and todays date is August 25th 2017. Now you can add 1 year to July 25th then you will get July 25th 2018. Difference between July 25th 2018 and August 25th 2017 is greater than 6 months so the date you want is past date, which is July 25th 2017 and vice versa. For more accuracy you can count in days instead of months
After converting Alexa's slot input date string to a js date object, (probably with amazon-date-parser) the below could work
if (dateobj > new Date()) {
var currentMonth = new Date().getMonth()
var dateMonth = dateobj.getMonth()
var offset = dateMonth > currentMonth ? 1 : 0 // if current month is to be set with past year use >=
dateobj.setFullYear(new Date().getFullYear() - offset);
}
Disclaimer: I am just looking for a logic not code
John discovered a strange island called Rasa. The years and weeks on the island are weird. Digging deeper into the island's calendar, he found out that it is similar to rest-of-the-world's (ROW) calendar but the island calendar's Year starts on 1st week of February's calendar. John is asking you to help him solve the problem of converting ROW's calendar into Island's calendar. Here is the question.
You are given a date (today's date). You have to determine the Island week's number. The catch here is that the Island year starts from 1st week of February and every Island's week starts from Sunday and ends on a Saturday. Write a SQL statement in SQL Server to achieve this. Use SQL Server functions and devise a logic.
Input parameter: Any date.
Output parameter: Week No in Rasa Calendar.
Here is an example:
Date: 5th May 2015 --
Week No in ROW Calendar:19
Week No in Rasa's Calendar:14
Date: Jan 1 2017:
Week No in ROW Calendar:1
Week No in Rasa's Calendar:49
My question: can this be achieved in SQL Server?
My homework: I tried a couple of ways to solve the problem.
Approach #1:
Step 1: Calculate the total no of days between today and Feb 1.
Step 2: Divide it by 7 and add 1 to the result.
Later found out that this approach will not work if Feb 1 is on any day other than Sunday.
Eg: 1st Feb is on Wednesday. 5th Feb will be on Monday
So, 1st Feb is on Rasa's week 1, and 5th Feb is on Rasa's week no 2. According to my approach 1st and 5th feb are on week 1 which is incorrect.
Approach #2:
I thought removing 5 weeks of Jan from ROW's calendar should work
select
case
when f.RasaWeek = -4 then 48
when f.RasaWeek = -3 then 49
when f.RasaWeek = -2 then 50
when f.RasaWeek = -1 then 51
when f.RasaWeek = 0 then 52
else
f.RasaWeek
end as Rasa_week,
f.year, f.month, f.date
from
(select
datepart(wk, date) - 5 as RasaWeek, *
from
<datetable>
where
Year(date) in (2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018)) as f
Info: I tested this on a <datetable> but this code will break if there is a 53rd week. Notice that I was not able to take care of the 53rd week.
Any inputs to solve this problem are welcome.
With dates, it's almost always easier to make a calendar table and store the data you care about rather than trying to do anything beyond basic date arithmetic. Use SQL's strengths: storing and retrieving data.
In this case, what you care about are all of the first Sundays in February. If you store these dates in a table, the solution is:
RETURN
SELECT TOP 1
DATEDIFF(day,[date],#input_date) / 7
FROM IslandCalendarStartDates
WHERE [date] <= #input
ORDER BY [date] DESC
This way you don't need to worry about leap years or 53-weeks, or any of the edge cases. Just count the days from the most recent first Sunday in February and divide by 7. If you need to change the solution to accommodate a different start date, you only change the data, not the code.
I have an ssrs matrix with total in rows and months as columns .. something like this .
Jan Feb March
Total1
Total2
I can choose a month as a parameter and my matrix shows the results for the month and the two months before the current month.
When I choose August :
I can see June July August
When I choose September :
I can see July August September
But when I choose October
I see October August September
My client wants to see it as August September October
I don't know the reason for this behavior .But can anyone help me with this ??
I tried doing the sort for the tablix as follows :
=(Fields!Month.Value)
Month is a number like 1 for Jan, 2 for Feb. I add it as a sorting expression but I dont see any change in the sorting.
according to your data.
August = "8"
September "9"
October = "10"
it looks to me like you need to convert your month to an integer type, Sort is picking up your month as a string value.
try converting your month field to an integer in your sort expression and then running rerunning the report.
something like:
=CInt(Fields!Month.Value)
I finally found what was going wrong with my solution .
I was adding the sorting on the "tablix properties" section .
Sorting needs to be added on the "Column group" and not on the "tablix properties" and this did the trick in my case. :-)
I have produced a report where the user will need to view financial years data.
So for example April 2010 - March 2011 will have one years data however if the user selects this as in my image, data for January, February, March in 2010 will be brought as well as January, Febrary and March 2011, when I dont want the Jan,Feb,Mar for 2010 as the financial year begins in April.
I therfore need to be able select a data range using parameters to stop bringing data through that I didnt ask for.
Can anyone advise me how to do this?
You can build a month-year key to use instead of your ad-hoc year and month parameters. You can then display it for example as YYYY/MM - so that you can select 2010/04 through 2011/03.
Another option would be to have from month (with year) to month (with year).
Yet another option would be to have a year, month, and number-of-months, selecting 2010, 04, then 12 for number-of-months.
Your two parameters aren't aware of eachother in the way that you want it to be.