Report Designer Work Calendar Date Difference - acumatica

I have a report that shows the days late for an order using the DateDiff function comparing today to a custom field we have called ShipBy. It works well enough in that I get the total days overdue, including weekends and holidays, but the customer needs to see it by Work Days overdue. In other words, exclude weekends and holidays so that it only shows the actual work days that an order is overdue.
Does the Report Designer have anything built in that can calculate a DateDiff using the Acumatica Work Calendar? Is there another way to go about this in the report designer other than creating a custom function and a DAC populated with the available Work Dates?

There's no formula function that I know of that allows that. Report formulas operate on primitive types, Acumatica work calendar is a complex type. Having scripting functions that works on Acumatica assemblies complex types would be redundant with the graph functions.
You can look up the Date/Time formula functions here:
https://help.acumatica.com/(W(25))/Wiki/ShowWiki.aspx?pageid=00a69dbb-c06b-4ce4-8b29-e86ee0e8ed47
The query builder in the report designer is also not a good fit for complex business rule. I believe you should use the appropriate layer for business rules code which is the graph.

I used this in a GI.
=(DateDiff('d', [PeriodStart], [Now])) + 1 - DateDiff('w', DateAdd([PeriodStart], 'd' , 0 -(DayOfWeek([PeriodStart]) -1)) , DateAdd([Now], 'd', 2 - DayOfWeek( [PeriodStart]) )) * 2 - Switch((DateDiff('d', [PeriodStart], [Now]) + 1) % 7 > 0 And DayOfWeek([PeriodStart]) = 1, 1,(DateDiff('d', [PeriodStart], [Now]) + 1) % 7 + DayOfWeek( [PeriodStart]) = 8, 1,(DateDiff('d', [PeriodStart], [Now]) + 1) % 7 + DayOfWeek( [PeriodStart]) > 8, 2,True, 0)

Related

Calculation with respect to dates is incorrect in oracle

I have to calculate some forumales based on Dates coming from table. For reference the exact value with formula is provided in Excel.
The formula and Excel answer is below.
Formula in Excel :
=IF(
D12>=DATE(2016,10,1),
(S12-T12)+(S12-T12)*2.5%
+(
IF(
ROUNDDOWN(YEARFRAC(DATE(2016,4,1),D12),0)=0,
0,
EFFECT(
(ROUNDDOWN(YEARFRAC(DATE(2016,4,1),D12),0)*2.5)%,
ROUNDDOWN(YEARFRAC(DATE(2016,4,1),D12),0)
)
)
)
*
((S12-T12)+((S12-T12)*2.5%)),
((S12-T12))
)
-(
IF(
AND(
D12>=DATE(2018,4,1),
D12<=DATE(2018,12,21),
E12<=DATE(2018,12,21)
),
7.69%*(S12-T12),
0
)
)
And the answer for which calculation in Excel is:- 30,153
and my answer coming is 28700/-
The value for D12 = 03/05/18 (dd/mm/yy) format, E12 = 21/04/19
S12 = 30000, T12 = 2000,
Here is my calculation logic provided in oracle.
IF TO_DATE(V_FINALSRDATE, 'dd-mm-yy') >= TO_DATE('01-10-2016', 'dd-mm-yy')
THEN
v_STD_REVISED_AMT := (V_STANDRD_AMT - v_OD_Discount) + (V_STANDRD_AMT - v_OD_Discount) * 2.5/ 100;
dbms_output.put_line( 'Standard revised amount 1: ' || v_STD_REVISED_AMT);
ELSE
v_STD_REVISED_AMT := (V_STANDRD_AMT - v_OD_Discount);
dbms_output.put_line( 'Standard revised amount 2: ' || v_STD_REVISED_AMT);
END IF;
Do I need to add one more IFELS part? Where is my logic failing?
Please help as where my logic is failing.
You are not doing the full calculation; you have calculated the (S12-T12)+(S12-T12)*2.5% but you have missed the second part of the calculation.
You need to implement an Oracle version of the YEARFRAC function using US (NASD) 30/360 day count basis (since you are not passing a 3rd argument to YEARFRAC) and then add in the second half of your Excel formula into your PL/SQL calculation.
If you want it to have the same behaviour as Excel then you will also need to implement all the bugs that Excel has as the documentation notes that:
The YEARFRAC function may return an incorrect result when using the US (NASD) 30/360 basis, and the start_date is the last day in February.
However, since the exact nature of the bug is not detailed, you will need to work out what the errors are and implement them yourself. But since you are using a start_date of 2016-04-01 then this may not apply (unless you also need to generalise this function for use elsewhere).
Alternatively, since you appear to be rounding the year fraction down to the nearest whole number then you are only calculating the number of full years between the dates and, instead of YEARFRAC, you could use:
EXTRACT( YEAR FROM (V_FINALSRDATE - DATE '2016-04-01') YEAR TO MONTH)
Or
FLOOR( MONTHS_BETWEEN( V_FINALSRDATE, DATE '2016-04-01' ) / 12 )

How do I calculate the number of years to target in Microsoft Excel

If I have an average YOY growth of say 2.5%, current year sales of $500,000, and target sales of $1,000,000. Is there a way to calculate the number of years until I hit my target (assuming a continued YOY growth rate of 2.5%), without calculating each additional years's sales on a different row?
You can use the NPER function for this:
=NPER(Growth,0,currentSales,-targetSales)
Note that this gives the same result as #Dominique, but is using a built-in Excel function.
Also, by virtue of the nature of Excel financial functions, the signs for the current and future Sales need to be different.
There's a simple formula for this:
Money_end = (1+r/100)^Y*Money_begin
Where:
Money_begin = the starting amount of money, in this case 500000.
Money_end = the finishing amount of money, in this case 1000000.
r = the percent ratio, in this case 2.5.
Y = the amount of years, which you are looking for.
So, your question comes down to solving this equation:
1000000 = (1+2.5/100)^Y * 500000
2 = 1.025^Y
Y = log(2)/log(1.025)
If you want this to be solved by Excel, you might use the formula and use the Solver basic Excel feature for coming up with the same (but numerical instead of analytical) result.

Determine number of days (not including weekend) based on hours given

I have two important details that are inputted into an excel table, Job_Start_Date and Job_Hours (meaning the hours required to complete the job). Given certain working hours (eg 7:00am-3:30pm) I need to calculate what day and what time they will finish. I already have that basic bit working, but I cannot for the life of me figure out how to skip weekends in that calculation (Note that there is a boolean for Sat/Sun that defines whether that day should be skipped).
Here is an example of the data
and an example of the data visualization: (The DIV errors are because employee count equals 0, pay this no mind.)
.
This is the formula used in the visualizer (a massive index match)
=IFNA(INDEX(INDIRECT(Allocation!$A$1), MATCH(1,($A3 = INDIRECT(Allocation!$K$1))
* (C$1 >= INDIRECT(Allocation!$C$1)) * (C$1 <= INDIRECT(Allocation!$D$1))
* IF(C$1 = INDIRECT(Allocation!$C$1), ($B3 >= INDIRECT(Allocation!$E$1)),
($B3 >= INDIRECT(Allocation!$I$1))) * IF(C$1 = INDIRECT(Allocation!$D$1),
($B3 < INDIRECT(Allocation!$F$1)), ($B3 < INDIRECT(Allocation!$J$1))), 0)),"")
As you can see in the image, Saturdays need to be skipped (being FALSE), but it is still shown on the visualizer. However, if I include a statement that matches the Saturday condition (so it only shows up on a Saturday if TRUE), it will not alter the end date and thus will not push the final day to Monday.
Essentially the question is: How can I skip days but preserve the 'working hours'. This must be done in excel formulas in the same Job table (first image).
Thanks.
Here is how I got it working using WORKDAY.INTL.
First is a nested IF to determine which weekend type to use for the workday.intl function
Weekend=IF(OR([#[JOB SATURDAY]], [#[JOB SUNDAY]]), IF(AND([#[JOB SATURDAY]], [#[JOB SUNDAY]]), -1, IF([#[JOB SATURDAY]], 11, 17)), 1)
Then a second if statement that references that value and then spits out the correct date
=IF([#[Weekend]] = -1, [#[JOB START DATE]]+[#[Working Days]], WORKDAY.INTL([#[JOB START DATE]], [#[Working Days]], [#[Weekend]]))

sum two values of dimension but show the result only in one of them in PowerPivot / DAX

It might be a easy one but I cannot solve it so please advice.
I would like to add up two months in a measure (like the current and the previous one) but when I represent the figure in a pivot table I want to show the result only in a current month.
Here is the formula I tried:
CALCULATE([Revenue],FILTER(Tbl_Period,Tbl_Period[Month_nr] = 3)) +CALCULATE([Revenue],FILTER(Tbl_Period,Tbl_Period[Month_nr] = 4))
But logically when I represent it in pivot table the revenue is appear under the two months:
See the picture of the result of the below formula:
What I want to achieve instead is the following:
See the picture of the aimed situation:
I already managed to solve with the ALL function to show the value in all the months but not only for July as I wanted. Here is the formula for that one:
Revenue:
=CALCULATE([Revenue],FILTER(ALL(Tbl_Period[Month_nr],Tbl_Period[Period_id]),Tbl_Period[Month_nr] = 3)) +CALCULATE([Revenue],FILTER(ALL(Tbl_Period[Month_nr],Tbl_Period[Period_id]),Tbl_Period[Month_nr] = 4))
Thanks in advance for the help!
I'm a little bit blind, since you haven't mentioned the structure of your Tbl_Period table.
There are many helpful functions built into dax that can save you a lot of work if you have a date table. One that would be relevant here is PREVIOUSMONTH().
Working with just the information you have provided, you can get a measure to show the previous month's revenue like this:
LastMonthRevenue: = CALCULATE([Revenue], FILTER(ALL(Tbl_Period), Tbl_Period[Month_Nr] = MAX(Tbl_Period[Month_Nr]) - 1))
and then
TwoMonthsRevenue: = [Revenue] + [LastMonthRevenue]

Issue with summing ageing in customized customer statement report

The requirement is to print the customer statement without credit memo and pre payment. I have modified the report and added a filter condition to filter only invoices and it works fine.
I am facing an issue in the ageing where the total is not tallying and it included the credit memo and prepayment.
I have tried to recalculate the values and it is not working.
How do I recalculate the ageing which considers the newly added filter condition?
I tangled with this report once and it was a tough exercise. My requirements were different,but in the end I had to tinker with how the variables within the report are calculated based on the data. In the report designer, click on the sections and then click into the variables collections under properties. You can see how the balances are summed and edit the code, put in if statements,etc. Hope that's helpful.
The have followed the below steps
Declared variable for each ageing group in detail band and the value will be reset on document group.
Declared a variable AgeingDays and calculated the date difference between statement date and document due date
=DateDiff( 'd', [ARStatementDetailInfo.DueDate],[#StatementDate] )
Used the following statement to find out the ageing group and stored the value
=$cagb00+Iif($AgeingDays < [ARStatement.AgeDays00], IIf([ARStatement.StatementType]=[#TypeOpenItem],[ARStatementDetailInfo.DocBalanceSigned],[ARStatementDetailInfo.OrigDocAmtSigned]),0)
=$cagb01+Iif($AgeingDays >= [ARStatement.AgeDays00] And $AgeingDays <[ARStatement.AgeDays01] , IIf([ARStatement.StatementType]=[#TypeOpenItem],[ARStatementDetailInfo.DocBalanceSigned],[ARStatementDetailInfo.OrigDocAmtSigned]),0)
=$cagb02+Iif($AgeingDays >= [ARStatement.AgeBalance02] And $AgeingDays < [ARStatement.AgeBalance03], IIf([ARStatement.StatementType]=[#TypeOpenItem],[ARStatementDetailInfo.DocBalanceSigned],[ARStatementDetailInfo.OrigDocAmtSigned]) , 0 )
=$cagb03+Iif($AgeingDays >[ARStatement.AgeBalance03] And $AgeingDays < [ARStatement.AgeBalance04], IIf([ARStatement.StatementType]=[#TypeOpenItem],[ARStatementDetailInfo.DocBalanceSigned],[ARStatementDetailInfo.OrigDocAmtSigned]),0)
=$cagb04+Iif( $AgeingDays >= [ARStatement.AgeDays04], IIf([ARStatement.StatementType]=[#TypeOpenItem],[ARStatementDetailInfo.DocBalanceSigned],[ARStatementDetailInfo.OrigDocAmtSigned]),0)
Declared another set of variable on to sum the value of group level
Finally while printing ageing value, check the flag invoice only and if it is true print the calculated value otherwise the default value
=Iif([#InvoiceOnly], $ca01, $CustAgeBalance01 )
I have tested and my test result are good.

Resources