Get first and last entry given a timespan - elasticsearch

I am using Kibana to log actions performed by the users of my web interface.
I would like to create a visualisation that does the following:
For each of my users (I have a field for that in my Elastic entries)
Display the first and last entry datetime
Maybe should I make two visualisations, on for first, one for last, as I don't know if it possible to do it on one single Visual.
Thanks in advance

Okay, I found the answer, in the case of a Data Table visualization, I added two metrics:
The min and max of the datetime field I use as the timestamp.
Changing the timespan of your visualization will give you the first and last entry datetimes.

Related

How to compare columns in a new column

I have a recordset where rows have a date field.Rows are from current year and last year. I want to see the count of rows per year. That's easy. Now I'd like to have a third column with difference (count(currentYear) - count(lastYear)). Is there any way to achieve this?
thanks
It seems like you want to have the difference calculated between two members of the same date field.
If so, you might want to consider the customizeCell() API call to retrieve the count values of each year, use them to calculate the difference, and modify the necessary cells with the result.
Alternatively, you could try modifying your data set so that the lastYear and currentYear are two different fields – this, for example, would allow you to compare them within a calculated value.

Can you remove drill through filter from measures in Power BI?

I am trying to use the drill through filter to take my user to other data related to that date. Essentially I have an overview page and I want the user to click on a date and drill through to the next page, where it will show them test scores nearest to that date.
I think I need to do two things 1) store the filter date as a variable so I can use it to find the nearest test date to the filtered date 2) create measures which ignore the filtered drill through date and can for example calculate the minimum or maximum test scores on all the tests overall.
I'm not sure if either of these options are possible but any help is greatly appreciated. TIA

Grafana elasticsearch time from now

I've configured Grafana to use Elasticsearch as a data source and prepared a few panels.
My document in ES index contains only a few fields. It describes some system actions, respectively there are such fields as userId, action date, and others.
Now I faced with the issue that I can't calculate the amount of time left when the action happened. I mean if the action happened 2 days ago, I need to have the number 2 in my table. Pretty simple I supposed.
I couldn't find any metric or transformation that can allow me to do it.
Any suggestion, help, please.
Resolved my issue with scripted field.
In table visualization, I just picked any numeric field, selected Min metric, and added script like next:
Instant Currentdate = Instant.ofEpochMilli(new Date().getTime());
Instant Startdate = Instant.ofEpochMilli(doc['activity'].value.getMillis());
ChronoUnit.DAYS.between(Startdate, Currentdate);
As a result, it shows me the number I needed.
I don't find this solution the best, so in case anybody know some better way to resolve this issue, please add a comment.

Filter values by hours in Power BI

I have a date table:
I need to filter this by hours. last 4h 12h 24h etc.
Relative date only gives me days-weeks and so on.
Simplest work-around could be to create a binary FLAG in the back-end to identify record created in the last 4h.
Then, define a slicer in the front-end (visible or hidden) to visualize only those records relevant for you.
Got this working by creating 4 new custom columns with code:
DateTime.IsInPreviousNHours([LastTransactionDate],4)
Which gives me values if TRUE or FALSE and can filter by turning off FALSE values.

Daily unique count, weekly unique count in the same Timelion chart

I want to visualize the unique count for a field aggregated daily and weekly per day in the same sheet. But timelion aggregation affects the entire sheet instead of just a single chart.
The expression I am using to get the daily unique count is
.es(metric='cardinality:userId').bars().title('Unique users over time')
If I change the bucket range on the right to 1d, I get the correct chart. How do I create the weekly aggregation?
There is a possibility to specify the interval used for timelion expressions by specifying interval as 1d or respectively 1w in the es() function. For details, please see the docs here.
In your case this should work with the following expression:
.es(metric='cardinality:userId',interval=1w).bars().title('Unique users per week')
Be aware of the comment inside the docs, stating that this should not be used in favor of working with the interval picker. But probably this is a use case where it is okay to do it like this...

Resources