Count of {field.name} where {field.name} = "No" - count

Good day; I am looking for help creating a running total or a formula where I can see a count of a specific field that equals "No".
Currently I have a total count of {ems_SceneCall.CrewDecison} for all decisions, and now I want to add a count of {ems_SceneCall.CrewDecison} = "No". I have had success with this up to the point where I want to count to reset with each group.
Currently I have a Running Total Set to count the field, Evaluate records where {ems_SceneCall.CrewDecison} = "No", and reset on change of group. This running total only shows 1 or 0.

Another way to do this is a formula that says
if {ems_SceneCall.CrewDecison} = "No" then 1 else 0
Then create a group summary (SUM) to the group footers

Related

Finding the percentage of a specific value in the column of a data set

I have a dataset called college, and one of the columns is 'accepted'. There are two values for this column - 1 (which means student was accepted) and 0 (which means student was not accepted). I was to find the accepted student percentage.
I did this...
table(college$accepted)
which gave me the frequency of 1 and 0. (1 = 44,224 and 0 = 75,166). I then manually added those two values together (119,390) and divided the 44,224/119,390. This is fine and gets me the value I was looking for. But I would really like to know how I could do this with R code, since I'm sure there is a way to do it that I just haven't thought of.
Thanks!
Perhaps you can use prop.table like below
prop.table(table(college$accepted))["1"]
If it's a simple 0/1 column then you only need take the column mean.
mean_accepted <- mean(df$accepted)
you could first sum the column, and the count the total number in the column
sum(college$accepted)/length(college$accepted)
To make the code more explicit and describe your intent better, I suggest using a condition to identify the cases that meet your criteria for inclusion. For example:
college$accepted == 1
Then take the average of the logical vector to compute the proportion (between 0 and 1), multiply by 100 to make it a percentage.
100 * mean(college$accepted == 1, na.rm = TRUE)

Multiple time periods comparison in Power BI / DAX

I have a question regarding a multiple-year comparison report in Power BI and DAX. The first five columns in the below table show the example data, the sixth column shows the two requirements, and the last column shows whether a plan _ID in the first column meets the requirement. I hope to count the number of plan_IDs which meet both requirements for a specific season (e. g. Spring 2018).
enter image description here
As you can see from the last column, Spring 2018 has 3 "yes" while Spring 2019 has 6. Therefore, for Spring 2019, the "Count of Plans for This Year" is 6 while the "Count of Plans for The Last Year" is 3, as shown in the table below. The table is what I want to have.
enter image description here
My question is how to count the plans that meet the two requirements for a specific season/season_number such as Spring 2019/190.
I have been struggling in this situation for a long time. Any ideas or suggestions will be greatly appreciated.
One of the best ways is to create comparative table (with an inactive relationship with the fact table), the user will have the possibility to choose any two time perdiods and the single visual will show the comparison : 
Here are two good videos explaining this subject fully:
https://www.youtube.com/watch?v=TF0lPIYjJfs
https://www.youtube.com/watch?v=knXFVf2ipro
If my understanding (as commented) is correct, just add a Custom Column to your table as below in the Power Query Editor-
Changed Type in line 2 is basically the Previous Step Name. Adjust this accordigly.
= Table.AddColumn(
#"Changed Type",
"counter or not",
each
let
current_year = Date.Year(DateTime.LocalNow()),
year_difference = current_year - [year] + 1,
current_date = DateTime.Date(DateTime.LocalNow()),
date_to_check_with = Date.AddYears(current_date,-(year_difference)),
meet_req = if [plan_date] <= date_to_check_with then "Yes" else "No"
in meet_req
)
And here is the final output-
Now your the column with Yes/No value. To count Yes per year, come back to report and create this below Measure-
yearly_yes_count =
CALCULATE(
COUNT(your_table_name[counted or not]),
FILTER(
ALLEXCEPT(your_table_name,your_table_name[year]),
your_table_name[counted or not] = "Yes"
)
)
Here is last year count-
last_year_yes_count =
VAR current_row_year = MIN(your_table_name[year])
RETURN
CALCULATE(
COUNT(your_table_name[counted or not]),
FILTER(
ALL(your_table_name),
your_table_name[counted or not] = "Yes"
&& your_table_name[Year] = current_row_year - 1
)
)
Now add Year and new measure yearly_yes_count to a table visual and the output will be as below-

Count object with maxnr in category with DAX

I am building a report in Power BI for all the calls we do.
Down below is a simplified version of the data I work with (we produce 1250 calls per hour, so my data is a lot bigger than this).
Every row is a call attempt, the first column defines who the attempt was to, the second in which week, the third the attemptnr and the last column states the status of the phone call.
For example: We called ID 1 two times, the first time in week 1 which ended in status 310 (means callback) and the second time in week 2 which ended in status 710 (positive conversion).
The problem: I want to make a count of all the people (Call ID's) who are still waiting on a phone call (last call status = 310).
If I use: CALCULATE(DISTINCTCOUNT(data[ID]), data[Status] = 310) the result = 3. Which makes sense: PBI counts 3 times a 310 status.
But it should count only 1, because ID 1 & 2 are already called back and have a positive result (710 & 711). So it needs to look to the highest attemptnr.
So I tried: CALCULATE(DISTINCTCOUNT(Blad1[ID]), FILTER(Blad1,MAX(Blad1[Attempt])), Blad1[Status] = 310) But this also results in a count of 3.
I've found solutions in which you make a calculated column, but I also want to combine this with a slicer on the weeknumber, so I can check what the callbacks in a specified week are.
So basically I need PBI to count the ID's with a certain status (310) with max attempt. Does anybody know how I can do this?

Number of times switched in longitudinal data

So, I have a time series with a number of observations per ID. I measure a 1/0 variable at each time point. I want to know how many times a person switches from 1 to 0 or 0 to 1.
There are missing data at random in each ID.
id=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
indicator=c(1,0,0,0,1,1,NA,1,1,0,1,0,NA,1,1,0)
timepoint=c(2003,2004,2005,2006)
td = data.frame(id,timepoint,indicator)
I need code to return the number of switches per person in these data.
To count the number switch from 0 to 1 or 1 to 0 all you need to do is shifting your vector and compare the two shifted versions. And they applying this function by id assuming your data is already sorted in chronological order.
library(data.table)
count.switch=function(x) sum(tail(x,-1)!= head(x,-1),na.rm=T)
td[,count.switch(indicator),keyby=.(id)]
With this method you could specify the switch you would like to count
count.switch.01=function(x) sum(tail(x,-1) == 0 & head(x,-1) ==1 ,na.rm=T)
You could also count both with a (==0 & ==1) | (==1 & ==0)
Another trick would be to count when the shifted vectors add up to 1 element wise. They only do when one element is 0 and the other 1.
count.switch=function(x) sum(tail(x,-1) + head(x,-1) == 1,na.rm=T)

How to get count of repeated values in datatable in asp.net

I want total count of repeated values in a datable.
as shown in image total count should be : 2 because repeated values are only 1 and 2.
I tried as given below:
DataView dv = new DataView(dtTemp);
int iRowCount = dv.ToTable(true, "Column1").Rows.Count;
but it returns 3 which is incorrect.
Does anyone knows how to do it.
I don't want to use loop becoz sometimes data table contains 4000-5000 rows so if we use loop it will take much more time to get the total count.
Thanks.

Resources