Calculate Running Count in Power BI based on two column context evaluation - count

I have a column called Weekly User Escalation which is a binary column indicating whether a user has been escalated or not in a specific calendar week. 1 for yes, 0 for no.
The data's granularity is dates (in one calendar week dates can also be missing and not always equal 7 days). So, for any calendar week, I can have 1-7 rows in my dataset.
Now, I want a column which sums up the escalation levels per user per CW. I.e., if User 1 has been escalated in Calendar Week 1 and 2 and not in CW 3, it should return 1+1+0=2, and so on.
What I tried already is this:
CALCULATE(SUMX('Data', MAX('Data'[Weekly User Escalation])), ALLEXCEPT('Data', 'Data'[User], 'Data'[Calendar Week]))
The output shows the sum of all the 1s and 0s in for that user, which in my case shows 13, since there were 13 rows which were "1" for a particular CW in my dataset. I want that only the MAX value from the column Weekly User Escalation, which is always 1, is counted AND ONLY ONCE for every CW.

Try with:
WeekWithEscalation = CALCULATE( Countrows( VALUES('Data'[Calendar Week]), 'Data'[Weekly User Escalation] = 1 )
If we put to visualization UserName and measure [WeekWithEscalation] that should work.

Related

Setting start date parameter to display in SSRS report as Day1

Is there a way to set the Start Date parameter to 1, next day would be 2, next day would be 3.
I would like to group on this and do day/week/month/year summaries.
I want to change the report that is attached to be a matrix report displaying days instead of dates starting with day 1 for whatever day is chosen. To go across the columns in a matrix and then aggregate those calculations to week/month/year summaries
Current Report by Date
I used the DAY function in SSRS. DAY(Fields!created_date.Value)

Netsuite saved search formula that sums distinct values within a date range

I am trying to create a saved search of time entries in Netsuite.
Under criteria, I have specified a date range. This varies as this is an available filter
For the purposes of this example, the date range is 1/4/2020 to 10/4/2020
The first column ('Total Customer Billable Hours') in this sums all time entries that are coded against project task type 'billable project'. The formula I am using for this:
Formula (Numeric), sum, Case when {project.task_type}='Billable' then {durationdecimal} else 0 end
For the second column, I want the sum of hours the employee would normally work (in the time period specified under criteria-1/4/2020 to 10/4/2020 in this example)
The formula I am using to sum this is
Formula(numeric), sum, {timesheet.workcalendarhoursdecimal}
However, this is multiplying the employee's weekly hours by the number of time entries that make up the 'Total customer billable hours' figure
i.e. if an employee works a 40 hour week, the formula is multiple 40 x 36 (the number of time entries that make up the customer billable figure for example)
What would the correct formula be so that the second column is only summing the employee's work calendar hours for the period specified in the criteria/available filter selection?
Try changing sum to maximum:
Formula(numeric), maximum, {timesheet.workcalendarhoursdecimal}

Excel - How do I match a minute in time series with specified minute to return max value from another column?

I am trying to extract the max values of CO2ppm (column E) that were logged every second over 1 hour (column D) for a total of 60 minutes (rows ~3300). I have column D for time (in HH:MM:SS) and CO2ppm (numeric). I have 50 CO2 samples that I collected that correspond with a minute (e.g. I collected sample #1 at minute 20:54 in F2), but the data is logging every second within that minute, and I want the the highest CO2 ppm in that minute).
The =MAX(IF(D:D=A2,E:E)) works to return the max value CO2ppm when I use the target value as the date (A2) for the entire day of sampling, but it does not work when I try to match my target minute (F2, 20:54) with the column D (HH:MM:SS). I tried to convert this column to text using =TEXT(D:D,"H:M") so that the target value will match the values of minute, excluding all of the seconds, but with no luck.
How can I match my minute (F2) with the range of rows that have that minute (20:54:xx, column D) to find the max value in column E?
Example data:
Thank you!
An easy way to do this would be to add a helper column with the timestamp stripped of the second component.
However in case that is not an option, you could use a formula like the following, which strips out the seconds from the timestamps in column D:
=MAX(IF((D2:D5-SECOND(D2:D5)/86400)=F2,E2:E5))
Depending on your version of Excel, you may have to confirm the formula with Ctrl+Shift+Enter.

why %new sessions by month differs from averaging %new sessions by each day of that month

I have the following problem,
I want to see the percentage of new sessions in a given month. I am specifically interested in new sessions by "direct" channelgrouping
in custom report I set dimensions for November: yearMonth, source, medium, channelgrouping. and metrics:percentNewSessions
it gives me 35%
then I create a custom reports with the same dimension but with Date as a metric.I average the %new session and get 38%
why does it differ? What should I trust?
Both of these measures are true, but they tell something different.
Another simple use case with date metric:
Day 1: visitor A
Day 1: visitor B
...
Day 7: visitor A
Day 7: visitor C
— Week unique visitors: 3
— Week sum of daily unique visitors: 4
Define your KPI, what is measured, how it is measured, the period for measurement, and always stick with the KPI parameters; else you're on another one :)

Count between months in Tableau

I am needing to count month between collect dates. I need to know if the test was run in the last 3 months. Below is the code I used but it is giving me a count of zero, but I know they had 3 of the same tests run in a year because I can see the dates. I understand the first one have a count of zero, because there is no test before that, but the count for the other should be 3, 5 respectively.
DATEDIFF('month',[Collect Date],[Collect Date])
Dates of the Tests.
1/8/2015
4/23/2015
9/30/2015
What you are looking for is possible using the LOOKUP function in Tableau. Keep in mind, that the result relies heavily on the data that is displayed and how it is displayed (sorted, etc).
You can create a calculated field like this:
DATEDIFF("month",LOOKUP(ATTR([Test Date]),-1),ATTR([Test Date]))
Which calculates the number of months between the date in the current row and the date from the prior row.
Your result will look something like this:

Resources