BO Webi - Looking to Display a Blank Instead of a Calculation - business-objects

I am trying to write a variable to display a blank instead of a calculated value. My report takes two date and time fields and subtracts them. Sometimes, one of the fields can be blank. This causes an issue because the variable will display a calculation instead of a null/blank. Attached a screenshot of sample data. I have included the formulas used below. Any suggestions would be a big help.
CT Time Diff (Started to Completed)
=(((DaysBetween([CT Exam Started Date & Time];[CT Completed Date & Time]))*1440)+(ToNumber(Substr(FormatDate([CT Completed Date & Time];"HH:mm:ss");1 ;2))-ToNumber(Substr(FormatDate([CT Exam Started Date & Time];"HH:mm:ss");1 ;2)))*60+(ToNumber(Substr(FormatDate([CT Completed Date & Time];"HH:mm:ss");4 ;2))-ToNumber(Substr(FormatDate([CT Exam Started Date & Time];"HH:mm:ss");4 ;2))))
CT Started to Completed Time (MM)
=If (([CT Time Diff (Started to Completed)]) >= 0) Then [CT Time Diff (Started to Completed)]

Adding an IsNull should do it:
=If [CT Time Diff (Started to Completed)]) >= 0
And Not(IsNull([CT Exam Started Date & Time]))
Then [CT Time Diff (Started to Completed)]
Your TimeDiff function is overly complex. Try:
=TimeBetween([CT Exam Started Date & Time];[CT Completed Date & Time];MinutePeriod)

Related

How to create rolling/moving average in ACCESS QUERY for the last 7 days,30 days Accumulative Avg?

My query name:
Total Daily Orders Summary
My Input [2 columns]:
business_date,# Daily Orders
I need these 3 columns as calculated output:
Orders# (7 days) Average, Orders# (30 Days) Average ,Orders# (Acuum Average) [i.e.from day one to date]
I have tried my best to find clear answers for how to do moving/rolling average in Microsoft Access query but unfortunately, I couldn't make it work for me. Therefore, I have decided to put my request here to see if someone will put me in the right direction to start working on my files and tasks.
I have trouble with correlated subqueries myself. here is a VBA/Access solution that I think is easier.
Start by adding a code module to your Database by clicking create on the menu and selecting module -which is all the way to the right.
Then create a public function like:
Public Function AverageOrders(CurrentDate As Date, NumberofPriorDays As Integer) As Integer
AverageOrders = DSum("DailyOrders", "MyTable", "business_date BETWEEN #" & CurrentDate & "# AND #" & DateAdd("d", -NumberofPriorDays, CurrentDate) & "#")
End Function
we create the function this way so access intellisense works. This is a powerful technique which I also use to wrap any calls to access form parameters. To find the function in a query right click on the top of a query column and choose build. In the build wizard under expression elements select functions then your database. Average Orders and any other public functions you make will appear. Or just type it.
then you get:
February has 28 days. We don't use # for DateOrders because In strings # denotes a date. To get the accumulated average just pick an absurdly early date or make another function without [NumberofPriorDays].

How do I tell google sheets to only make a calculation after a certain time period?

Context
So I am currently building a database of data for financial assets to conduct some machine learning from to build trading signals. I am trying to calculate the geometric mean but over a given period (monthly). I want to tell google sheets to only calculate the geometric mean after every month. I tried using this formula to no avail:
=IF(last date of the month - first date of month = total days in a month,
GEOMEAN(filter(abs(range),abs(range)>0)),""))
** There were values in the last date of the month - first date of month = total days in a month **
It ended up doing it for every day for the 10 year data set.
** Update
This is the data:
Date Close Cleaned Data Returns Gross returns Geometric average returns
13/11/2015 280 -0.0267 0 1
16/11/2015 280 -0.0267 0 1
17/11/2015 280 -0.0267 0 1
...
23/12/2016 296.4 0.0236 -0.1561348935 0.8438651065
28/12/2016 295.2 0.0199 -0.0770931339 0.9229068661
29/12/2016 294.7 0.0183 0.03341318035 1.03341318
30/12/2016 294.9 0.0190 0.3718276303 1.37182763
Problem (UPDATE)
How do I create a function to let google sheet do calculations only for the last day of every month for a given time series data? Say within this time period, (1 year) I want to calculate the geometric mean for each month in this period and for new data I might want to add later in the future.
To do this you will have to set a trigger event. This is found within the script editor under the edit tab, second to last option.
Image of where to find the trigger manager: It's in spanish, but it will be found in the same place
Once there, click on add trigger, which will be found on the bottom right corner. The first option will ask you which function do you want to run from the bound script. Then select the source of the event and select according to time (My platform is in spanish so I'm trasnlating it you might have it written differently). Then it will prompt you: if you want it to be at an exact date and time, every minute, every hour, day, week and month. Select month and select the day of the month you want the trigger to happen in the next prompt and select the time for the last prompt, then click save.
Finding the last day of a month:
function lastdayOfMonths() {
let html='';
let td=new Date();
for(var i=0;i<12;i++) {
let dt=new Date(td.getFullYear(),td.getMonth()+i+1,0);
let dts=Utilities.formatDate(dt, Session.getScriptTimeZone(),"E MMM dd,yyyy");
html+=Utilities.formatString('<br />%s',dts);
}
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), "Last Days of Months for next year");
}

Set last month ending balance to next month open balance: Power Query M Function

Using a Power Query M function, I am trying to set current month's ending balance to be next month's opening balance. I have tried various different date functions (i.e. Date.IsInPreviousMonth) but cannot get this to work.
The attached image shows what I am trying to accomplish using Power Query M formula.
This is possible with M but is quite complex. Here is a PowerBI Community post that gives options.
I would prefer to use DAX's PREVIOUSMONTH function as opposed to M.
Create a new measure along the lines of:
Previous Month Balance =
CALCULATE(SUM('Fact - Sales'[Cost Price]),
PREVIOUSMONTH('Dimension - Calendar'[Date]))

Current and Previous Month Revenue in Report

In Access 2013, I have a report showing revenue for each month of the year. I was success in getting a formula to name the previous month:
=Format$(DateAdd("m",-1,([ApptDate])),"mmmm",0,0)
What I am trying to get, is the revenue for the previous month for comparison, like a distribution chart. This is as close as I have gotten to something working, but the sum of the revenue for the previous month is too low (maybe only for a day's revenue?) Could anyone please help me put the following formula in the right order with right parameters to get the date needed?
=Sum(DateAdd("m",-1,([revenue])))
If I understood your problem correctly, you could use the DSum function by setting as criteria the month of the date to the previous month.
=DSum("[revenue]","YourTableName","Month([ApptDate])=" & Month(DateAdd("m",-1,Date())))

Amount of time between two dates in Microsoft Access in specific format

I have a table named "Resolved Request", in which I have two specific columns: Date Assigned and Date Resolved. I have a third column named Time Spent Resolving, which should be the amount of time between Date Assigned and Date Resolved, in days hours and minutes. I am using MS Access 2013 but the file I am modifying has to be compatible with MS Access 2007.
I know how to calculate the difference between two dates (Date1-Date2 as calculated column), however I cannot get the format I want. I need for example to have Time Spent Resolving show up as "34 days, 2 hours and 5 minutes". How would I retrieve the amount of time between two dates in that kind of format within MS Access?
Also as an added bonus question, the "Date Assigned" field is a duplicate of a field I have in another table named "In Progress Request". Would I be able to calculate the difference between "Date Resolved" in "Resolved Request" and "Date Assigned" in "In Progress Request"? If not, could I somehow link both Date Assigned fields in both tables to update each other automatically?
Here is the formula that you need to display the format that you require (34 days, 2 hours and 5 minutes). I don't think you should have this formula for a calculated column as it's a waste of space in your table.
Replace txtInsertDateTime and txtAuditDateTime in the formula with the columns that you have.
=CStr((DateDiff("n",[txtInsertDateTime],[txtAuditDateTime])\60)\24) & " days," & CStr((DateDiff("n",[txtInsertDateTime],[txtAuditDateTime])/60) Mod 24) & " hours and " & CStr(DateDiff("n",[txtInsertDateTime],[txtAuditDateTime]) Mod 60) & " minutes"
Not sure about your bonus question, so cannot answer.