How can I calculate my win rate on one column based on the date on another? - date

I created a rudimentary Google Form to track my win rate at Starcraft. The first column on the resulting Google Sheet is Timestamp created by the form.
I have another column that has my win-loss, and I am able to calculate my percentage for the entire sheet (all games). However, I want to be able to see my daily win rate, and I can't figure out the correct way to go about it.
I tried COUNTIF, COUNTIFS, with TODAY() and I was able to count the games for a certain day, but I don't know how to use it to tie in with my win-loss column. What I currently do is adjust my Daily formula to specify today's date before playing. I was hoping I won't need to do this.
Please see Win-Loss Stats Sheet

Solution:
You can extend your formula to compare against the date in column A:
=(COUNTIFS(D2:D, "Win", ARRAYFORMULA(INT(A2:A)),TODAY())/((COUNTIFS(D2:D, "Win",ARRAYFORMULA(INT(A2:A)),TODAY()))+(COUNTIFS(D2:D, "Loss",ARRAYFORMULA(INT(A2:A)),TODAY()))))
The additional condition would be ARRAYFORMULA(INT(A2:A)),TODAY(), which converts the timestamps into dates and compares them to today's date.
Sample Output:

Related

Relative Date filtering Query Editor - Power BI

I don't understand the logic of Power Query Editor.
I have a big table with data from 2019 to 2024 (one column contains the monthly information).
I want to filter the data by the date of that column, but it has to be dynamic.
Two options:
The data I want to consider is "Current month -2". So all historical data minus current month.
The data I want to consider is a parameter extracted from somewhere (e.g. I set the latest month to consider manually somewhere in an Excel, which usually is "current month -1" but not always (best).
I would be happy with any of the two solutions.
Currently I found somewhere this formula which filters out vs last month:
= Table.SelectRows(#"Changed Type",each [Month]< Date.From(Date.StartOfMonth(DateTime.LocalNow())))
But somehow I do not find the way to go 2 months back.
Thanks a lot!
BR

Webi: How to use double slider input control with dates?

My boss asked me to add a double slider input control for the date information on a report on Webi.
We have several columns and two of them display a date (start and end date of procedure). So I need to have two double slider, one for each date.
I've been searching for a whole day now and I know that it is not directly possible to use double slider with dates, because double slider only works with values (measures) and dates don't have that.
But I managed to create two more variables on the business layer. I used the following SQL function:
CAST(currentDate as Bigint))
These variables are displaying the date as numbers (e.g. 1090101 for 01.01.2009 (format is "dd-MM-yyyy")).
And it is working great! But it displays the dates as number, which is not possible to use for work. No one will know which date is 1090101. I could perhaps let both columns (date as date and date as number) in the report, so people could check the date they want to filter with the input control and select the right number on the slider. This could be a workaround, but not a clean one, I think.
I tried to change the format of the date as number to a date format, but then I could not use the slider anymore (even if the variable is a number).
I looked for a way to change the formatting of the values displayed on the slider, but with no luck.
So I'm asking for your help. Does anyone know how I could make this work?
Is there really no solutions for such a useful way of filtering data? I mean, filtering data by an interval of dates is surely something people want to do quite often, I assume.
Thank you in advance for your time.
(Version Webi : SAP BusinessObjects BI Platform 4.2 Support Pack 8 Patch 6,
Version: 14.2.8.3671)
You could format your date value as year, month, day and then convert it to a number so the value you are filtering on makes a little more sense. Like this...
=ToNumber(FormatDate([Your Date];"yyyyMMdd"))
It will be better than just an arbitrary number, but certainly not perfect since you will have large chunks of your range for which there never will be any corresponding data (e.g. 20211232 through 20220100).
What is wrong with just a Minimum and Maximum input controls? They are more intuitive and simple to create. Sometimes what your user or boss asks for is a bad idea and/or just not possible.

PowerBI, DAX. Is there a way to set an upper limit to a slicer?

I'm trying to create some measures using DAX on an underlying data model which I would then use for creating some visuals (line chart, bar chart etc.). Each table in the data model has a data field (date&time) that contains repeated dates and times (more occurencies with the same date&time). To use the metrics in the visuals I need the measures to be grouped for date (only date, not for time).
To achieve the task I've created a calendar table (using CALENDAR in DAX) to set-up a set of dates (only dates) to which refer at for every table in the data model and created relations (dates that points to calendar date) for every table. I set the upper limit of the calendar table to be a year ahead of the max date in the dataset, because some measures need to be evaluated in the future.
In the visual pages, I put a slicer that points to the calendar table dates, but the date interval is too wide. I need the slicer to have a more narrow interval, let's say, only "for the present and the past" but I prefer not to add another calculated table.
In your opinion, is there a way to limit the slicer without changing its reference to the calendar table?
Thanks!
For the calendar you may just use CALENDARAUTO(). It will expand automatically as the data model expands.
For the slicer, just select it, open the filter pane and define a filter with the upper limit you want.
You can use combination of 3 different slicer for your purpose. This is just another option that you can have a look on. There will be 3 slicer for Year, Month & Date. So Date slicer is you final slicer, with 2 other slicer on top of it to generate necessary Dates in the slicer. This way, you are not making any static restriction to generate the Date list but giving the user full control on the Date range. Here below is a sample how the slicers can be look in practical.
User can select any year or multiple year, any month or multiple month. Finally the date slicer will hold Date values accordingly.

Loading date or datetime into date dimension

Let's say I have a date dimension and from my business requirements I know that the most granular I would need to go is to examine the specific day of the month that an event occurred.
The data I am given provides me with the exact time that an event occurred (YYYY-MM-DD HH:MM:SS). I have two opitons:
Before loading the data into the date dimension, slice the HH:MM:SS from the date.
Create the time attributes in my date dimension and insert the full date time.
The way I see it, I should go with the option 1. This would remove redundant data and save some space. However, if I go with option 2, should the business requirements ever change or if my manager suddenly wants to be more granular I wouldn't need to modify my original design. Which option is more commonly used? Are there more options that I did not consider?
Update - follow up question
I receive new data every month. If I used a pre built date dimension with all the dates would I then need to run my script every month to populate the table with new dates of that month or would I have a continuous process where by every day insert into the table one row, which would be that date?
I would agree with you and avoid option 2. A standard date dimension table is at the individual date level. If you did need to analyse by time of day, you could create an additional time of day dimension at the level of a second in a single day, and link to that from your fact table.
Your date dimension should be created by script automatically, rather than from the dates that events occurred. This allows you to analyse across a range of events from other facts, and on dates where no events occur, using a standard, prebuilt dimension.
I would also include the full date/time stamp as a column in the fact table, along with the 'DateKey' to the dimension table. This would allow you some visibility/analysis of the timestamp, you would not lose the data, and would still allow you to analyse by the date dimension.
Update - follow up question
Your pre-built date dimension (the standard way of doing it) would usually contain some dates in the future. There's no reason not to, for example, include another 5 years of dates in the table. But if you'd like it to gradually grow over time, you could have a script that is run once a day, once a month, or once a year to add new dates. Its totally up to you! There are many example scripts for building date dimensions- just google date dimension script. They exist for the language of your choice, e.g. SQL, C#, Power Query, etc.

Creating Bins in Tableau for Days in a Week

Could someone please explain me creating BINS based on Weekdays in Tableau? I tried creating different Calculation Fields but it won't work
You're working too hard.
Tableau already knows how to bin values by dates at many levels of granualarity: such as year, month, day, weekday, hour etc. So you don't need to create a new field to bin dates by the day of the week. (creating bins is not difficult, it's just already available in this case)
Just put a discrete (blue) date or datetime field on a shelf. You'll see the date level of granularity displayed like, say, YEAR(MyDateField) with a leading plus sign.
You can either
click on the plus sign to drill down by adding a second level, say MONTH(MyDateField)
or
right click on the field to select the date level of granularity you want
Alex's Answer is exactly correct, Tableau will perform the operation automatically. What is great about is that you can select various formats (Full day name, number, 1 letter or 3 letter day etc.).
However if you absolutely need to you can used this formula:
datepart('weekday',[Date])
to give you the 1 (Sunday) to 7 (Saturday) value if you need it for something other reason, say another calculation.