I have a report I am trying to modify in Crystal. It has a data field that has a formula in it, but I want to use another formula.
This is an example of what I am trying to do.
[((# Days in January) – 15) x (Market Rent/(# Days in January))]
+ [((# Days in February) – 0) x (Market Rent/(# Days in February))]
+ [14 x (Market Rent/(# Days in March))]
I have ADO commands built out for the market rent, and a start date and end date. The months in my example are just that an example. I am not sure how to take my ADO command dates that are entered in on a filter page, and put them in a formula like the one above. Any ideas?
Also, in the first and last para. the -15 and the 14 are for a date in the middle of the month. So if the start date was on the 15th of Jan, and the End date was the 15th of march. This formula would calculate my loss of rent during vacancy.
If I'm reading your question correctly, you want to take a date field and find out how to measure the number of days in that month, the month before it, and the month after it. Here's some Crystal formulas to help you out. Let's assume your date field is called {#DateFld}:
To find the number of days in a particular month relative to a particular date, try this:
local datevar X:=cdate(dateadd("m",0,{#DateFld}));
datediff(
"d",
date(year(X),month(X),1),
date(year(X),month(X)+1,1)
)
I recommend you copy & paste this in 3 different formulas:
- In the 1st formula, replace the "0" with a -1 to get the number of days in the previous month.
- In the 2nd formula, don't change anything. That'll get you the number of days in the current month (i.e. the month that {#DateFld} is in)
- In the 3rd formula, replace the "0" with a +1 to get the number of days in the next month.
For example, if {#DateFld} is March 10th, 2011, the 1st formula will give you 28, the 2nd will give you 31, and the 3rd will give you 30.
Related
I have 2 rows. One row has dates and the other row has numbers.
I want to build a google sheet formula that allows me to sum 10 days after the next Saturday. So if today is Monday 7/22/2019, I want the sum from Sunday (7/28/2019) through and including the next 9 days. If today was Tuesday (7/23/2019) the formula would return the same result, because it's always starting from the next Sunday.
Another way I'm looking at it is the sum of the 10 days after the current week number since google has the weeks beginning with Sunday.
Thanks for your help.
My current array formula is using weeknumber:
sumifs(rowwithnumbers,weeknum(rowwithdates),">"&weeknum(today()),weeknum(rowwithdates),"<="&weeknum(Today())+2))
but that gives me the next 14 days, which is close but not exactly what I want. I don't want to sum the next 2 weeks after the current week, I want to sum the next 1o days after the current week.
=ARRAYFORMULA(SUM(INDIRECT(
ADDRESS(2, MATCH(VLOOKUP(WEEKNUM(TODAY())+1, {WEEKNUM(ROW(INDIRECT(
"A"&DATEVALUE(TODAY())&":A"&DATEVALUE(TODAY()+8)))),ROW(INDIRECT(
"A"&DATEVALUE(TODAY())&":A"&DATEVALUE(TODAY()+8)))}, 2, 0), 1:1, 0), 4)&":"&
ADDRESS(2, MATCH(VLOOKUP(WEEKNUM(TODAY())+1, {WEEKNUM(ROW(INDIRECT(
"A"&DATEVALUE(TODAY())&":A"&DATEVALUE(TODAY()+8)))),ROW(INDIRECT(
"A"&DATEVALUE(TODAY())&":A"&DATEVALUE(TODAY()+8)))}, 2, 0), 1:1, 0)+9, 4))))
Although you could put it all in one formula, I think for clarity and debugging it would be good to use a separate sheet (call it "Dates") for the date calculations. Then use the results of the date calculations as arguments to your SUMIFS function.
In that case, the date calculation for the next Saturday is:
=IF(WEEKDAY(TODAY()) = 7, TODAY() + 7, TODAY() + 7-WEEKDAY(TODAY()))
That checks if today is a Saturday, and if it is, uses today plus 7 days. Otherwise, it just adds the number of days until the upcoming Saturday. If you store that cell in B2, for example, then you can calculate your end date with a simple:
=B2+10
If you store that in C2 of the "Dates" Sheet, and your value list is in a Sheet called "Values" with dates in column A and the numbers in column B, then your sum function is:
=SUMIFS(Values!$B:$B,Values!$A:$A, ">= " & Dates!B2, Values!$A:$A, "<= " & Dates!C2)
Here is a link to a Google Sheet showing all of above: Google Sheet
I need to count number of weeks in a fiscal year starting with Oct 1. My fiscal year goes from Oct 1st to September 30th.
When I apply:
ATTR(datepart('week',[Generation Date]))
It counts the weeks, but it starts in January. My data properties and default properties are set to October.
Instead of using inbuild week function you can create your own week number by just calculating date difference from fiscal year starting and then dividing by 7 then just take the next possible integer to get your week.
Let me know if you need exact formula
You should filter the dates by adding conditions using IF in a calculated field. In your case something like this if your fiscal year is fixed from Oct 1st to September 30th:
Write the following Formula in a Calculated field:
IF ([Generation Date] >= #01-10-2017#) AND [Generation Date] <= #30-09-2018#)
THEN [Generation Date]
END
Now use this calculated field the way you were using it before:
ATTR(DATEPART('week',[Calculated field]))
I have a data set that has dates for many years. I can easily filter the data by month or week, but I was hoping to change the X axis to make it start in October and end in April.
Is there a way to do this in Tableau without altering the original data and listed dates?
I don't know about it ending in April since that would not be a full 12 months but you can make it start in October. Right click on your date field > Default Properties > Fiscal Year Start. Then select October.
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.
I have a crystal report that shows sales volumes called week to date volume. It shows current week, previous week, and average week. The report prompts for a date parameter and I extract the week number to get current week and previous week volumes. Did it this way because Mngmt wants to be able to run report whenever. My problem is for Average Week I cant figure out how to get the number of weeks to divide by for my average. Report originates from June 1st, 2010. Right now I have:
DATEPART("ww", {?date}) - DATEPART("ww", DATE(2010, 6, 1))
This returns 2 right now which is perfect, so i divide my total by 2. This code will work until the end of the year then I'm hooped. Any idea how I can make this a little more dynamic. I was thinking a counter somehow, just can't get the logic down because the date parameter will keep changing, meaning I cant increase my counter by 1 after each week???
Cheers.
Look into the Crystal Reports method: DateDiff.