Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GrischkePro
Regular Visitor

COUNTIFS (if) dates meet criteria

Hi all,

 

I have a list in SharePoint Online called Training Matrix. It contains all employees and tens of columns with Course names and those contain a date of training.

 

Each course has a different frequency, but let's assume all courses here should be completed every 12 months and there are 7 employees in each department. So, dates within last 12 months should be counted as "In date" and dates that are over 12 months old should be counted as "Out of date". I got number of staff per department sorted, I just want to show a percantage of how many staff are trained per department.

 

SharePoint list (Training Matrix):

EmployeeDepartmentFireH&SGDPR
Amy FittockDept C13/10/201805/09/201705/09/2017
Bernarda ChauezDept A01/11/201801/01/201704/02/2018
Carlyn PreciadoDept A01/05/201702/07/201801/05/2017
Catrice GayleDept B01/01/201704/02/201801/11/2018
Clarita NettoDept A01/02/201604/09/201824/07/2018
Delorse MariettaDept B01/01/201704/02/201801/11/2018
Elayne OrdDept B04/09/201824/07/201801/02/2016
Fernanda HardageDept A01/02/201604/09/201824/07/2018
Jeanelle JimersonDept C24/07/201801/02/201604/09/2018
Jerri TamuraDept C01/05/201701/05/201702/07/2018
Kaila PidgeonDept B04/09/201824/07/201801/02/2016
Kenton SowardsDept C24/07/201801/02/201604/09/2018
Layne WaggonerDept A05/09/201705/09/201713/10/2018
Madlyn MichaelDept C04/02/201801/11/201801/01/2017
Mellissa WatchmanDept B02/07/201801/05/201701/05/2017
Nicola SaidDept C04/02/201801/11/201801/01/2017
Ryann MisnerDept C13/10/201805/09/201705/09/2017
Senaida HippertDept A05/09/201705/09/201713/10/2018
Sharlene McclurgDept B05/09/201713/10/201805/09/2017
Soila PatoutDept B05/09/201713/10/201805/09/2017
Tyisha FlytheDept A01/11/201801/01/201704/02/2018

 

 

I want this in Power BI:

 Dept A   Dept B   Dept C   
 # of staff per deptIn DateOut of date% of staff trained# of staff per deptIn DateOut of date% of staff trained# of staff per deptIn DateOut of date% of staff trained
Fire72529%73443%76186%
H&S73443%76186%72529%
GDPR76186%72529%73443%

 

I then want to display results graphically, per department, per course etc (I think this part should be easier).

 

I would apreciate any advise on how to achieve this 🙂

5 REPLIES 5
GrischkePro
Regular Visitor

Hi all,

 

I'm not gonna bore you with how new I am to Power BI so I'll start now with my question 😉

 

I have a list in SharePoint Online called Training Matrix. It contains all employees and tens of columns with Course names and those contain a date of training.

 

Each course has a different frequency, but let's assume all courses here should be completed every 12 months and there are 7 staff members in each department. So, dates within last 12 months should be counted as "In date" and dates that are over 12 months old should be counted as "Out of date". I got number of staff per department sorted, I just want to show a percantage of how many staff are trained per department.

 

SharePoint list (Training Matrix):

EmployeeDepartmentFireH&SGDPR
Amy FittockDept C13/10/201805/09/201705/09/2017
Bernarda ChauezDept A01/11/201801/01/201704/02/2018
Carlyn PreciadoDept A01/05/201702/07/201801/05/2017
Catrice GayleDept B01/01/201704/02/201801/11/2018
Clarita NettoDept A01/02/201604/09/201824/07/2018
Delorse MariettaDept B01/01/201704/02/201801/11/2018
Elayne OrdDept B04/09/201824/07/201801/02/2016
Fernanda HardageDept A01/02/201604/09/201824/07/2018
Jeanelle JimersonDept C24/07/201801/02/201604/09/2018
Jerri TamuraDept C01/05/201701/05/201702/07/2018
Kaila PidgeonDept B04/09/201824/07/201801/02/2016
Kenton SowardsDept C24/07/201801/02/201604/09/2018
Layne WaggonerDept A05/09/201705/09/201713/10/2018
Madlyn MichaelDept C04/02/201801/11/201801/01/2017
Mellissa WatchmanDept B02/07/201801/05/201701/05/2017
Nicola SaidDept C04/02/201801/11/201801/01/2017
Ryann MisnerDept C13/10/201805/09/201705/09/2017
Senaida HippertDept A05/09/201705/09/201713/10/2018
Sharlene McclurgDept B05/09/201713/10/201805/09/2017
Soila PatoutDept B05/09/201713/10/201805/09/2017
Tyisha FlytheDept A01/11/201801/01/201704/02/2018

 

 

and I want this in Power BI:

 Dept A   Dept B   Dept C   
 # of staff per deptIn DateOut of date% of staff trained# of staff per deptIn DateOut of date% of staff trained# of staff per deptIn DateOut of date% of staff trained
Fire72529%73443%76186%
H&S73443%76186%72529%
GDPR76186%72529%73443%

 

I then want to display results graphically, per department, per course etc (I think this part should be easier).

 

I would apreciate any advise on how to achieve this 🙂

dedelman_clng
Community Champion
Community Champion

I have everything for you except for the exact format of the table that you want, but if that's just for reference this ought to work for you.

 

In Edit Query, highlight the 3 date columns, go to the Transform tab and click "Unpivot Columns"

 

unpivot.png

 

Rename the columns "Training Type" and "Training Date"

 

rename.png

 

Back in the Report, create a calculated column DateStatus (adjust logic as needed)

 

 

DateStatus =
IF (
    DATEDIFF ( Training[Training Date], TODAY (), MONTH ) < 12,
    "In Date",
    "Out of Date"
)

 

Create a measure Pct Trained

 

Pct Trained =
DIVIDE (
    CALCULATE ( COUNTA ( Training[Employee] ), Training[DateStatus] = "In Date" ),
    CALCULATE ( COUNTA ( Training[Employee] ), ALL ( Training[DateStatus] ) )
)

 

This will give you what you need.  You can create a matrix with Training Type as the rows, Dept and Training Status as the columns, and count of Employee as the value

 

matrix.png

I couldn't get Pct Trained in the matrix as well without it repeating inside each department. But if you want Pct trained for graphs, etc, this should give you the setup you need.

 

Hope this helps

David

Thank you so much David. I'm almost there, but I'm having some difficulties in understanting how to build the final table, similar to your last screenshot.

 

I'd appreciate an advice on this 🙂

 

Thanks,

Maciek

@GrischkePro,

 

You may drag the measures below to Values.

# of staff per dept =
COUNT ( Training[Employee] )
In Date =
CALCULATE (
    [# of staff per dept],
    DATEDIFF ( Training[Training Date], TODAY (), MONTH ) <= 12
)
Out of date =
CALCULATE (
    [# of staff per dept],
    DATEDIFF ( Training[Training Date], TODAY (), MONTH ) > 12
)
% of staff trained =
DIVIDE ( [In Date], [# of staff per dept] )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, I'm getting there.

 

What I didn't mention was that some date fields are empty and those are considered as training not completed.

 

So, in the table below some training has not yet been completed.

 

EmployeeDepartmentFireH&SGDPR
Amy FittockDept C13/10/201805/09/201705/09/2017
Bernarda ChauezDept A 01/01/201704/02/2018
Carlyn PreciadoDept A01/05/201702/07/2018 
Catrice GayleDept B01/01/2017 01/11/2018
Clarita NettoDept A N/A04/09/201824/07/2018

 

When I unpivoted the table, all blank fields have been removed. How can I keep them so that I can count empty fields as well?

 

Also, some employees are not required to complete specific training and they will have something like N/A in the date field.

 

There's 500 employees in total. Table below represents the entire organisation, I will then break it down per dept. I suppose I will count N/As as 'completed' or I will deduct N/As from All Employees so that the true percentage is reflected in the graph.

 

Something like this.

 

Training TypeAll EmployeesIn DateOut of DateNot CompletedNot Required
Fire500400503020
H&S500500000
GDPR500495005

 

Another difficulty I foresee is that not all courses are valid for only 12 months. Some are 36 months and some are just one off. I'm interested to know how I will be able to overcome this. Maybe by adding conditional column..

 

How can I achieve this?

 

Thanks,

Maciek

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.