How to add different values in the same row with conditionals of date - google sheets - google-sheets-formula

I have a file where I keep track of the sessions that I have with clients. **The issue is that I have 1 row for each client **and in different columns I register the date and in another one how was the meeting.
Remember: Each client has its own row. I want to know the date of each session with each mode per year
For example
Name: John Doe - Session 1: 04/04/2021 - Mode: Virtual - Sessión 2: 05/04/2021 - Mode: P2P - Session 3: 04/04/2022 - Mode: Virtual
What I want to know if how can I know how many sessions where given in 2021 and 2022 and with which mode (example: 2 sessions in 2021 - Virtual 1 / P2P 1; 1 session in 2022 - 1 virtual)
I add a picture of my sheet:
Google sheet example
I tried count if but I can only get how many sessions where given in a time (2 sessions in 2021 and 1 in 2022) but I don't know which mode was each session
This is my formula how I know the dates: =CONTAR.SI.CONJUNTO(AN2:CX2,">="&FECHA(2022,1,1),AN2:CX2,"<="&FECHA(2022,12,31)) but this formula does not tell me the mode.

Related

How to deal with reporting slowly changing dimensions

For a client I am creating a data warehouse in which we have some slowly changing dimensions (or facts if that is even a thing?). For example we want to report the annually recurring revenue (ARR) for subscriptions and we want to have both the currently active and the expired subscriptions in there. So that we can see the ARR over a timeline.
The data we retrieve looks like this:
subscription_id
account_id
ARR
start_date
end_date
1
1
10
01-01-2022
31-03-2022
2
2
20
01-01-2022
31-12-2022
3
1
5
01-04-2022
31-11-2022
So in this case the same account (account_id 1) renewed a subscription at the 01-04-2022. In the report of 2022 we want to see the ARR for all months in 2022. I've looked into slowly changing dimensions, however something I can not really see in that concept is how to report both the currently active license and the history in a dashboard. If we for example want to visualize the ARR in all of 2022 per month in a dashboarding tool we want to see both subscriptions for account_id 1 over the course of the year, not just the currently active one. This seems to be very tricky to do in most dashboarding tools.
To overcome this I've done the following. I created a calendar table with an interval of 1 month and I cross join it with the table above to generate a fact table. The end result would look like:
timestamp
account_id
ARR
01-01-2022
1
10
01-01-2022
2
20
01-02-2022
1
10
...
...
...
01-11-2022
1
10
01-11-2022
2
20
01-11-2022
2
20
This makes it really easy for the user of the reporting tool to filter on a specific month and show the ARR between the dates and over multiple subscriptions. It does however generate a lot of extra data, but at the moment the storage space is not an issue. And it makes it more of a transactional style table, but the ARR is not really a transaction (i.e. it is not really a sold product on a specific date).
My question is: Are there better ways of generating a fact table where the source data contains a date range?

How to change pgsql now() time?

I'm having an error on my system with some timescale matherialized views, but this only happens after 22 hrs.
I can´t access the office's computer at that hour and I should not be working at that time, so for me to debug the problem I would like to change the computer's time to pretend it's 22 at 9 am.
I changed the computer's time and restarted the psql docker image, but it still marks the current time when select now().
I can find many posts and documentation about changing the timezone, but I just want the server to belive that current time is today's late night.
Is there any way for doing this?
thanks
ps: I'm working on windows 10, and pg12.
You can change the time of your session, so that you can perform your tests, e.g. current time - 5 hours
SELECT now();
now
-------------------------------
2022-02-03 13:01:35.580786+00
(1 row)
SET timezone = -5;
SELECT now();
now
-------------------------------
2022-02-03 08:01:47.569613-05
(1 row)
Demo: db<>fiddle

Running Sum of Filtered Rows in Tableau

I have a table of challenge submissions (that records the time of submission of a challenge in a competition by different players, and whether the submission was correct or not) -
and another table that has the points associated with each challenge -
How do I plot a graph of running sum of points earned by the top 3 players in the competition over time (for last 24 hours only)? The catch here is that I only need to consider the first successful submission in case there are more than one successful submissions for a challenge in the competition (eg. Challenge #17 for Player A).
EDIT:
Dummy Data
Desired Output:
I am proposing a solution/answer assuming a few things-
Challenge acceptance time ends at 17:00 everyday
Different lines represent different challenges
Step-1 Create a CF to adjust date/time by calendar date - adjusted date as
DATEADD('hour', 7, [Date])
Note that I have added 7 hours to make the last calendar date/time for submission as 00 AM next day.
Step-2 Create another CF win_loss as
If [Success]='W' then 1 ELSE 0 end
step-3 create another CF game points as
[win_loss]*[Points (Points)]
Step-4 create another CF first win or loss as (don't worry about loss here)
{FIXED [Player], [Challenge], [success] : MIN([Date])} = [Date]
Step-5 create a set on 'players' field with TOP-3 with this formula (select top 3) by
sum(
IF [first win or loss]= TRUE
then [game points] END)
Step-6 build your view by dragging
set, MDY(adjusted date) & first win or loss on filters shelf/card
add mdy filter to context
[date] with exact date and discreet to columns
sum(game points) to rows
adding table calculation on measure - running total
right click sum(game points) click edit in shelf and replace the existing calculation by this one-
RUNNING_SUM(ZN(SUM([game points])))
(Note this will ensure your lines start at f(x)=0 always)
challenge on colors in marks card
sum(game points) to text in marks card.
Note- filters on (i) Set will ensure the top 3 players are in view only
(ii) adjusted date will ensure view for 24 hour challenge submission time
(iii) first win or loss will eliminate second and subsequent win(s) by same player for same challenge
I hope this will also make things clear to you.
You should get your desired view
OR change the date field to seconds to get a view like this

Sort by problems with Matomo

I’m working on a Custom Report in Matomo, an I’m experiencing some problems with the sorting of the columns.
The setup is as following:
Report type:
- Table
Dimensions:
- Server Time - Week of Year (End of visit)
Metrics:
- Visits
- Total Number of Internal Searches
No filter is used.
My problem is that the report is sorted by “Visits" as default.
Can this somehow be changed to “Server Time - Week of Year” instead?
If you click on title "Server Time - Week of Year (End of visit)", the data should be sorted based on that.

Complex Queries in ELK?

I've successfully set-up ELK stack. ELK gives me great insights on data. However, I'm not sure how I'll fetch the following result.
Let say, I've a column user_id and action. The values in action can be installed , activated, engagement and click. So, I want that if a particular user has performed an activity installed on 21 May and 21 June, then while fetching results for the month of June, ELK should not return those users who has already performed that activity earlier before. For eg, for the following table:-
Date UserID Activityin the previous month
1 May 1 Activated
3 May 2 Activated
6 May 1 Click
8 May 2 Activated
11 June 1 Activated
12 June 1 Activated
13 June 1 Click
User1 and User2 has activated on 1May and 3May respectively. User2 has also activated on 8May. So, when I filter the users for the month of May having activity Activated, it should return me count 2, ie
1 May 1 Activated
3 May 2 Activated
User2 on 8May is being removed because it has performed that same activity before.
Now if I write the same query for the month of June, it should return me nothing, because the same users have perform the same activity earlier as well.
How can I write this query in ELK?
This type of relational query is not possible with ElasticSearch.
You would need to add another column (FirstUserAction) and either populate it when the data is loaded, or schedule a task (in whatever scripting/programming language you're comfortable with) to periodically calculate and update the values for this column.

Resources