How to calculate the hourly Max over a month, promql - promql

I have the following query, intended to calculate for each hour the max value, over a month.
The final result should be- for each parentnode, the hourly max over the last month
I have this for now:
max_over_time((node_memory_MemTotal_bytes{site="fra",parentnode="compute_node"} - node_memory_MemFree_bytes{site="fra",parentnode="compute_node"} - node_memory_Cached_bytes{site="fra",parentnode="compute_node"} - node_memory_Buffers_bytes{site="fra",parentnode="compute_node"} - node_memory_Slab_bytes{site="fra",parentnode="compute_node"})[1h])
Thank you.

You will either have to use subqueries (blog post) or recording rules (example) to first calculate the avg per hour for a month and then max over time for a month.
With subqueries your query would look like this:
max_over_time(avg_over_time(node_memory[1h])[30d:5m])
You can play around with the resolution. But I recommend recording rules once you have worked out your panels

Related

How to get average time in Cognos 11

I am working on a data where I have to calculate average time attendance for days of the week or month
Our Data source is Cognos 11
how to get average time in Cognos 11?
Create a list with day of week, etc and your metric - calculated time
Group by day of week
Select from the swing out menu (I think it's the third option) Summarize, then choose average
Depending on the data source/database you will want to convert your start times to the lowest level (maybe minutes)
Either use a timediff function or if you have to, build it yourself (see below for suggestions on how to do that)
To build the number of minutes yourself, see if there are functions like Hour() and Minute() to deconstruct this.
Hours from time = hour([Start Time])
Take the hours and divide by 60
Add this to the minutes. Now you have total minutes
Total Minutes = ([Hours from time] * 60) + [Minute]
Take the average across the users (or whatever grouping you want) to get the average time per week
Average Minutes = average([Total Minutes] for [Work Date])
Then take the average minutes and convert that back to the time

Calculate difference between two dates to calculate hours and minutes

I would like to get the difference in hours and minutes between two dates with the numbers after the colon in the number of minutes for a SharePoint List on SharePoint 2013. For example:
1st Date: 1/5/2019 1:00 AM
2nd Date: 1/6/2019 2:15 AM
Total: 25:15
=INT((([Date Time Test]-Created)*1440)/60) this gives total of hours. If I remove the 60, that gives total number of minutes or I have tried this: =INT((([Date Time Test]-Created)*24) which also gives the number of hours.
The way I see it, you will need three calculated columns:
one to calculate hours
one to calculate minutes
last one displays the hours & minutes
The big disadvantage of this approach is that all three columns will have to be included in the relevant views.
Second approach (depending on your SP version) - have a workflow calculate hours & minutes and output the result to a single line of text column.
Lastly you can also consider column formatting, depending on SP version again.
You could try to CONCATENATE the hours and minutes, for example:
=CONCATENATE(INT((([SDate]-Created)*1440)/60),":",INT(([SDate]-Created)*1440))

Can I get the average value for each hour in Excel? Different amount of data for each hour

I have about 160k rows of data which consists of temperatures and flow rates. I need to get it down to being a bit more manageable. I would like to have an average temperature and flow rate each hour instead of several values each minute. I'm not much of a programmer but I don't think this would be a problem if it were the case that I had the same amount of measurements each hour, which is not the case. Each hour has between 200-400 data points and I'm not sure how I would go about this problem. The output I want is something like
date - hr - average1 - average 2 ... and so on.
How the sheet looks
Does anyone have a suggestion of how to go about this?
Sincerely,
This is how it looks in a pivot table. I've put in some dummy data which has two different days and two different times to test it.
To get the date without the time I've used
=floor(B2,1)
because date-times are stored as decimal numbers where the whole number part contains the date and the fraction part contains the time.
To get the hour I've just used
=hour(B2)
My test data looks like this
and the resulting pivot table looks like this
I had to use Value Field Settings and Number Format to tidy up the formatting of the date and average columns.

Powerpivot data that spans over multiple filter values

I have outage information stored in Excel Powerpivot. I am trying to use Powerpivot to display and calculate uptime availability per month, however, I am a bit stuck with outages that spans over two months.
My current setup:
Outage table has four columns: Application, Outage Start Time, Outage End Time, Duration. Duration is a calculated column that is the difference between the end time and start time.
The Outage Start Time is connected to a date table. I have slicers per month, so users can select the month they like to see availablity data, and powerpivot table will show availability for that month for different applications.
If the outage start time and end time falls within the same month, then availablity calculation is correct. However, for example, if the outage starts at the end of July and ends at the beginning of August, then this is only considered to be an outage for July (because of how the start time is tied to the date table). Ideally, I would like to see the duration of this outage split up over both July and August. Is this possible?
Thanks!
Tallie,
It's absolutely possible! I solved it by creating 2 calculated columns on the Outage Table:
One to determine the duration of the outage in the current month:
=if([End]>EOMONTH([Start],0),EOMONTH([Start],0)-[Start],[End]-[Start])
And another to determine the outage in the following month:
=if([End]>EOMONTH([Start],0),[end]-EOMONTH([Start],0),blank())
It then becomes the slightly more complex where I want to create a measure that not only sums the current month outage but also the following month outage from the previous month. I began by creating a measure that sums each of the 2 calculated columns respectively - this is good practice as it helps a logical build up and improves performance:
[Cur Month Dur] = sum(Outage[Cur Month Outage])
[Following Month Dur] = sum(Outage[Following Month Outage])
I then add to the [Cur Month Dur] a filtered version of the [Following Month Dur] which opens the filter context of the measure and looks in the date table for the previous month (must be numeric):
=[Cur Month Dur] +
CALCULATE([Following Month Dur],
FILTER(
ALL(dimDate),
dimDate[Month Number]=max(dimDate[Month Number])-1
)
)
You can find a detailed explanation of the method here.
I uploaded my workings to SkyDrive which you might find useful.
HTH
Jacob

How to get the difference in minutes between two dates in Microsoft Excel?

I am doing some work in Excel and am running into a bit of a problem. The instruments I am working with save the date and the time of the measurements and I can read this data into Excel with the following format:
A B
1 Date: Time:
2 12/11/12 2:36:25
3 12/12/12 1:46:14
What I am looking to do is find the difference in the two date/time stamps in mins so that I can create a decay curve from the data. So In Excel, I am looking to Make this (if the number of mins in this example is wrong I just calculated it by hand quickly):
A B C
1 Date: Time: Time Elapsed (Minutes)
2 12/11/12 2:36:25 -
3 12/12/12 1:46:14 1436.82
I Have looked around for a bit and found several methods for the difference in time but they always assume that the dates are the same. I exaggerated the time between my measurements some but that roll over of days is what is causing me grief. Any suggestions or hints as to how to go about this would be great. Even If I could find the difference between the date and times in hrs or days in a decimal format, I could just multiple by a constant to get my answer. Please note, I do have experience with programming and Excel but please explain in details. I sometimes get lost in steps.
time and date are both stored as numerical, decimal values (floating point actually). Dates are the whole numbers and time is the decimal part (1/24 = 1 hour, 1/24*1/60 is one minute etc...)
Date-time difference is calculated as:
date2-date1
time2-time1
which will give you the answer in days, now multiply by 24 (hours in day) and then by 60 (minutes in hour) and you are there:
time elapsed = ((date2-date1) + (time2-time1)) * 24 * 60
or
C3 = ((A3-A2)+(B3-B2))*24*60
To add a bit more perspective, Excel stores date and times as serial numbers.
Here is a Reference material to read up.
I would suggest you to use the following:
Combine date to it's time and then do the difference. So it will not cause you any issues of next day or anything.
Please refer to the image with calculations. You may leave your total minutes cell as general or number format.
MS EXCEL Article: Calculate the difference between two times
Example as per this article
Neat way to do this is:
=MOD(end-start,1)*24
where start and end are formatted as "09:00" and "17:00"
Midnight shift
If start and end time are on the same day the MOD function does not affect anything. If the end time crosses midnight, and the end is earlier then start (say you start 23PM and finish 1AM, so result is 2 hours), the MOD function flips the sign of the difference.
Note that this formula calculates the difference between two times (actually two dates) as decimal value. If you want to see the result as time, display the result as time (ctrl+shift+2).
https://exceljet.net/formula/time-difference-in-hours-as-decimal-value
get n day between two dates, by using days360 function =days360(dateA,dateB)
find minute with this formula using timeA as reference =(timeB-$timeA+n*"24:00")*1440
voila you get minutes between two time and dates
I think =TEXT(<cellA> - <cellB>; "[h]:mm:ss") is a more concise answer. This way, you can have your column as a datetime.

Resources