DateHistogram Facet return ZERO if nothing took place at certain time - elasticsearch

I am using a date histogram to get the count per hour of some messages in elastic search.
However the date histogram facet will only show the count per hour in the hours were some activity took place. Is there a way to force it to return zero if no activity happened during that interval.

This is just how it works, we have some code in place on our end to populate missing "buckets" with zeros. I'm not sure yet if this is a good design decision or a bug - perhaps open an issue for it on http://github.com/elasticsearch/elasticsearch ?

Related

DAX ignore row context in measure. Calculate for a defined set of dates and show the value for all dates in visual

I am trying to create a measure which calculates the average daily revenue per customer, but only using days in a 6 months period prior to a specific date (where some type of conversion happens).
This specific date can be different for each customer.
The intention is to use the measure as a baseline for indexing daily average in the days/months/years after said conversion date.
If I put my current version of the measure in a card it works just fine (circled in green). But I will eventually have to visualize this over time as well. Thus I need the value to stay the same regardless of the row/date context in a table or timeline (circled in orange).
I suspect I need to use one of the ALL/ALLSELECTED/ALLEXCEPT filter modifiers but I can't really get anything to work.
The measure looks like this for now:
Average daily rev before conversion = CALCULATE (
AVERAGEX(
VALUES('Date'[Date]),
[HI & Acc Rev]
),
FILTER('poc vFact_SalesLine','poc vFact_SalesLine'[OrderDate_ID] IN DATESINPERIOD('Date'[Date],FIRSTNONBLANK('poc vDim_Customer'[DSE first conversion date],1),-6,MONTH)))
I've tried adding REMOVEFILTERS('Date'[Date]) just before the filtering of order dates, but that doesn't work. Gives me the exact same values as shown below.
All help is very welcome? Is my approach all wrong?

Fixed time range for a grafana panel

I'm using several time series panels on my dashboards, which are showing the values based on the selected time range.
Now, I want to add a gauge panel, which should show the number of payment transactions since midnight (although I know all the problems about server restarts, the feature of the rate function, etc. the gauge panel will an interesting part of my dashboard). So my query has to be independant from the selected time range of the dashboard.
I've found the variables ${__from} und ${__to} in the Grafana docs, but I'm not sure, how I can use them in a query or how to use them flexibel, e.g. getting the current daten/time as "to" and calculating "from" als midnight value.
Has anybody an idea, if this is generally possible?
Thanks in advance
Matthias

Visualization in Elasticsearch using customized query

Here's the situation I have, suppose my index document looks like this :
{
"user" : 1
"started" : "2021-06-05"
"finished" : -1
"status": "ONGOING"
}
{
"user" : 2
"started" : "2021-06-05"
"finished" : "2021-06-06"
"status": "DONE"
}
Like this I have 100 docs indexed. The ongoing documents have -1 as the finished time and completed once have a valid timestamp. I want to visualize a graph that can give me the number of ongoing applications with the "started" field in the X-axis.
In the date histogram, I'm only able to get the filtered ongoing processes for that specific interval. But I want the count for the ongoing application to be counted for every interval until the document is updated with the finish time.
Is there anyway I can visualize this in Kibana? Even an elastic search query that can give me this output will do.
This is really similar to a problem I had and have now solved. I spent ages trying to create a query that does this to no avail, but luckily this can be achieved using Vega's transforms.
If you want to bin it evenly, not using start time as your x-values Here is the posted solution (look for my answer). The one thing I would add is; for the documents where you have "-1" as the finished time, if you do a formula transform you can round these to the end bin times.
However, if you still want to stick to the "started"/"finished" field being the points of summation/evaluation this is also possible. I'll give you a quick rundown on how to do this...
Method:
First thing you need to do is create two copies of your data with a common field referring to the "timestamp". The first dataset will have the "started" value assigned to the field "timestamp" (started dataset) and the second will have "finished" (finished dateset). You can achieve this using the formula transform.
You will then need to create a column in each dataset named "operation" referring to what that that data entry does - add a user or remove a user. For the finished dataset you want to assign a column of '-1's and the started dataset '1's. Again using formula transforms.
Then join these datasets back up. You now need to order by "timestamp" and cumulatively sum the "operation" column up. This can be achieved using the window transform.
This should give you the data needed to plot it. Arguably this is much more accurate than binning, but if your data set is large it can yield quite messy results - binning in this case is much cleaner.
Good luck, there is obviously a lot to fill in but a working example would of taken me quite a while to draw up - plus where is the fun in copying.

How to calculate the current value of depreciated asset?

I'm aware of various depreciation formulas in google sheets, but to me it seems like non of them provide and cumulative value. So if I wanted to calculate the current value of a car bought 6 months ago, I'd have to have multiple rows calculating depreciation per month, and then I'd have to sum the depreciation over months (cells). Is there a way to put everything in one cell? Example:
https://docs.google.com/spreadsheets/d/1u3py5XG9IPBAMQXGmG0q-kyg60fxJ72Gy8C90Za1FTg
Columns A:F is working fine, but I want to be able to be able to have a list of multiple assets with todays (depriciated) value, like in columns H:P .
Any idea how I could achieve that?
Even though this is very brief, I want to record the comment that helped answer this question.
Will the VDB function work for you?
You enter:
VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch]).
So Purchase Price - VDB(...) is the current asset value, after a specific period of time, of the asset's lifespan.
Specify start_period as zero, and end period as the number of years (or fractions) that have passed, and the result is the total depreciation over that time period. It defaults to give a DDB (Double Declining Balance depreciation) answer, but the rate (factor) can be modified. Hope this helps. I'm sure there are other options

Query that discards duplicate keys with parse.com SDK?

I'm researching how to implement leaderboards for my game with the parse.com SDK, my plan is to submit a score for the user every time they finish a level, attached to a "parent" leaderboard. I need to submit all scores because I need to retrieve leaderboards within time ranges (eg "all time", "last week", "last month", etc). The problem is, there'll be multiple scores for each user on the same leaderboard, and I only need to highest one. Is there a way to drop duplicate keys from a query? Is this the correct strategy? Everything else (sorting, paging, etc) seems to be in place.
Thanks.
You just need a table with 'User_id', 'Score', 'Level', and 'Date' (or whatever you need). Each time that a player finishes a level, you put the score into the table.
Then you have to calculate each (all time, last week, etc) in the query.
E.g.
10 Highs of the day:
SELECT TOP 10 User_id, Score, Date FROM Scores
WHERE Date = getdate()
ORDER BY Score DESC
I don't know if I understood the question. Let me know if I didn't.
Hope it helps.
As far as I understand from your question you want to retrieve data from Parse class. At the same time you want to eliminate the duplicate entry because user has multiple scores in different days. So to get the highest one, you have to query the class via query (based on SDK Android,iOS) and order by descending(based on your criteria), then obtain the first item in the result.
Or you can get the user all scores and create a structure where you can store the user scores as array list day by day. Based on day you can get the latest max or min scores. I hope I understand your question.
Hope this helps.Regards

Resources