Display number of rows if they are placed in date/time range - spotfire

I have a table with info about different tasks with following structure
id start_time finish_time
1 20.12.2018 16:12:06 20.12.2018 16:18:52
2 20.12.2018 16:15:03 20.12.2018 16:22:48
3 20.12.2018 16:18:04 20.12.2018 16:25:23
I would like to create bar chart with visualization about how many tasks are processed in each moment of time: binned datetime by minutes on X-axis and Count for rows on Y-axis.
As was planned before, the first row from example table should be counted in each bar in range from 16:12 to 16:18. But I only was able to make spotfire count values on the column that was binned on X-axis (finish_time)
So there is two questions
How to make spotfire take into account values wihin range from start_time and finish_time?
Is it possible to bin X-axis by date time without binding formula to a column? For example the whole time range for the last year?

Related

How to build a simple moving average measure

I want to build a measure to get the simple moving average for each day. I have a cube with a single table containing stock market information.
Schema
The expected result is that for each date, this measure shows the closing price average of the X previous days to that date.
For example, for the date 2013-02-28 and for X = 5 days, this measure would show the average closing price for the days 2013-02-28, 2013-02-27, 2013-02-26, 2013-02-25, 2013-02-22. The closing values of those days are summed, and then divided by 5.
The same would be done for each of the rows.
Example dashboard
Maybe it could be achieved just with the function tt..agg.mean() but indicating those X previous days in the scope parameter.
The problem is that I am not sure how to obtain the X previous days for each of the dates dynamically so that I can use them in a measure.
You can compute a sliding average you can use the cumulative scope as referenced in the atoti documentation https://docs.atoti.io/latest/lib/atoti.scope.html#atoti.scope.cumulative.
By passing a tuple containing the date range, in your case ("-5D", None) you will be able to calculate a sliding average over the past 5 days for each date in your data.
The resulting Python code would be:
import atoti as tt
// session setup
...
m, l = cube.measures, cube.levels
// measure setup
...
tt.agg.mean(m["ClosingPrice"], scope=tt.scope.cumulative(l["date"], window=("-5D", None)))

Fill Series with 1m frequency skipping weekends

I have currency quotes in pandas dataframe, column 0 - date/time, column 1 - close price.
And as its a 1 minute period, there are a lot of gaps.
So I need to apply .asfreq(freq='T') on close series, but also I must skip all weekends.
How do I do that? Unfourtunately, .asfreq(freq='BT') doesnt work
data = data.asfreq('15T')
data = data[data.index.dayofweek<5]
It works this way.

How to make a categorical count bar plot with time on x-axis

I want to count the number of occurrences of categories in a variable and plot it against time.
The data looks like following:
Date_column Categorical_variable
20-01-2019 A
20-01-2019 B
20-01-2019 C
21-01-2019 A
21-02-2019 A
22-02-2019 B
........................
23-04-2020 A
I want to show that in month of Jan I had 1 occurrence of B/C whereas 2 occurrences of A. In feb, I had 1 occurrence of A/B and so on. The bar plots can be stacked to know the total number of occurrences.
I've been very close to it. But haven't been able to draw plot out of it.
df['Date_column'].groupby([df.Date_column.dt.year, df.Date_column.dt.month]).agg('count')
The other way is to change the dates to 1st of every month, and then group by to count a occurence. But I'm unable to draw plot out of it.
df.groupby(df['Date_column'], df['Categorical_variable']).count()
Use crosstab with Series.dt.to_period:
df['Date_column'] = pd.to_datetime(df['Date_column'])
df = pd.crosstab(df['Date_column'].dt.to_period('m'), df['Categorical_variable'])
df.plot.bar()

How to Combine Columns with the Same Heading in Excel

I have a set of cost data for different pieces of unique equipment. Each piece of equipment is classified as a particular equipment class which I have pulled from an index match on the unique equipment number. I now have a set of ~9000 columns of cost data, each with a column header of one of the ~300 equipment classes.
What I want to do is to get the median, 25%, and 75% for the full data set for each of these equipment classes.
I either want to create a single long column of all the data for each equipment class, or have a way to calculate the Percentile() values for the data in all columns with the same heading.
I could filter the data for each equipment class one at a time and calculate the percentile values, but with 300 equipment classes it would take forever.
Example:
Class01 Class02 Class01 Class03 Class03
1 4 7 10 13
2 5 8 11 14
3 6 9 12 15
And I want the 25%, median and 75% for the distribution for Class01, Class02, and Class03
Thank you for your time.
I either want to create a single long column of all the data for each equipment class, or have a way to calculate the Percentile() values for the data in all columns with the same heading.
I'll just tell you how to change your data around. From there the percentiles/ quartiles will be straight forward.
Start with your data like this. Notice that I added a column on the left. It's easy to make, just type Item1 and drag down (or double click the small square in the bottom right corner of the cell)
You then need to hit Alt+D+P.
Select multiple consolidated ranges > next
Next (create page ranges for me...)
Select all of your data as the range, click add then finish
You will now get a pivot table that looks like this:
Click the grand-grand total (i.e. 120) and that will create another pivot table like this:
Et voila...

how to show 0 data point in visualization when data is missing in data table?

i have one visualization,
on x-axis i have months of date column,
on Y-axis i have unique count of issues.
i have 2 filters in text area,
when i am selecting some values in filter 1 or filter 2 than if count is not available for any month than i need 0 for that month.
Lets suppose i have 5 month(Jan to may) data in my data table, i selected 1 value from filter 1 and 1 value from filter 2, if that combination data is not available for march and April, than trend should show 0 count for march and April.
it is a trend line so if count is not available for any month for selected filters than it should show 0. any lead will help.
TIA
Go to the x-axis settings of your vizualization, click on settings next to your month variable and with the categorical options, choose show all values. If you have a bar chart it will show you the 0 values. In a line chart Spotfire will continue the line as if there are no missing values. In this case you need to add markers to your line.
1:

Resources