Forum Discussion
Iterate through multiple columns to produce a value
I am trying to write a method in Power BI to select the last date in a column but iterates through other columns and then counts the number of occurences of that time stamp.
Provided below is an example. I have a table of hundreds of employees and every employee has several skills that can be in different status of completion and a time log of each time the status changes. When the status changes, the previous status keeps it time stamp and new value is created for the new status. With a slicer for Status, I want to have a card that shows the count of the last date over a time range, which a time slicer would be used to change the range. From the example below, if the slicer was selected as Status = Not Verified, the card should display 2. That is because it is only selecting the skills for each employee where Not Verified is the last time stamp. I highlighted those two values in red text show which two I am referring to.
In other words, for every employee and each of their skills, count the last status for that skill. The Date/Time column seems to be the log of the most current status of that skill. I was researching how to apply a for loop for this but I could not figure that out with DAX.
Example table:
| Employee Name | Skill Name | Status | Date/Time |
| Employee 1 | Coding | Not Verified | 2/23/23 10:00:00 |
| Employee 1 | Coding | Submitted | 2/23/23 10:30:00 |
| Employee 1 | Writing | Not Verified | 2/23/23 10:00:00 |
| Employee 2 | Coding | Not Verified | 2/23/23 10:00:00 |
| Employee 2 | Coding | Submitted | 2/23/23 10:15:00 |
| Employee 2 | Coding | Verified | 2/23/23 11:00:00 |
| Employee 3 | Communication | Not Verified | 2/23/23 12:00:00 |
Anonymous
Do you mean like this?
Skill Count = CALCULATE ( SUMX ( SUMMARIZE ( 'Table', 'Table'[Employee Name], 'Table'[Skill Name], 'Table'[Status] ), IF ( CALCULATE ( MAX ( 'Table'[Date/Time] ) ) = CALCULATE ( MAX ( 'Table'[Date/Time] ), ALL ( 'Table'[Date/Time], 'Table'[Status] ), ALL ( 'Status' ) ), 1 ) ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
16 Replies
- tamerj1
Community Champion
Hi Anonymous
Please provide more examples- AnonymousNot applicable
In the table below Employee 1 has 11 unique Skill Names, which you can see has multiple Status per Skill Name and some have repeated values from changing of those statuses. With a slicer selected as Status = Not Verified, the total should show 7 by returning back 1 Status with the Status as Not Verified per Skill Name. Because that Status can be multiple times per Skill Name, the latest Date/Time should be selected.
Employee Name Skill Name Status Date/Time Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Adaptability & Flexibility Verified 8/21/19 12:20 Employee 1 Managing Work Verified 8/21/19 12:20 Employee 1 Senior / Lead Claim Processing Technician Not verified 8/21/19 12:20 Employee 1 Adaptability & Flexibility Submitted 8/22/19 17:12 Employee 1 Quality Orientation Not verified 9/24/19 20:27 Employee 1 Initiating Action Submitted 9/24/19 20:27 Employee 1 Quality Orientation Submitted 9/24/19 20:27 Employee 1 System Architecture Submitted 9/24/19 20:27 Employee 2 Quality Orientation Submitted 9/24/19 20:28 Employee 2 Senior / Lead Claim Processing Technician Submitted 9/24/19 20:28 Employee 2 System Architecture Submitted 9/24/19 20:28 Employee 1 System Architecture Verified 10/14/19 19:18 Employee 1 Quality Orientation Not verified 10/14/19 19:18 Employee 1 Senior / Lead Claim Processing Technician Submitted 10/15/19 1:39 Employee 3 Quality Orientation Not verified 10/16/19 16:21 Employee 3 System Architecture Verified 10/16/19 16:21 Employee 1 Active Listening Not verified 10/17/19 22:34 Employee 1 Responsible Not verified 10/17/19 22:34 Employee 1 Stress Tolerance Not verified 10/17/19 22:34 Employee 1 High School Diploma or equivalent Not verified 10/23/19 19:21 Employee 4 Infrastructure Submitted 11/14/19 17:35 Employee 4 Presenting & Communicating Information Submitted 11/14/19 17:35 Here is the same table but with only Employee 1 and sorted by Skill Name then Date/Time to more easily understand the example above. The table above was sorted by Date/Time as it would normally appear.
Employee Name Skill Name Status Date/Time Employee 1 Active Listening Not verified 10/17/19 22:34 Employee 1 Adaptability & Flexibility Submitted 8/22/19 17:12 Employee 1 Adaptability & Flexibility Verified 8/21/19 12:20 Employee 1 High School Diploma or equivalent Not verified 10/23/19 19:21 Employee 1 Initiating Action Submitted 9/24/19 20:27 Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Interpersonal Not verified 8/21/19 12:17 Employee 1 Managing Work Verified 8/21/19 12:20 Employee 1 Quality Orientation Not verified 10/14/19 19:18 Employee 1 Quality Orientation Submitted 9/24/19 20:27 Employee 1 Quality Orientation Not verified 9/24/19 20:27 Employee 1 Responsible Not verified 10/17/19 22:34 Employee 1 Senior / Lead Claim Processing Technician Submitted 10/15/19 1:39 Employee 1 Senior / Lead Claim Processing Technician Not verified 8/21/19 12:20 Employee 1 Stress Tolerance Not verified 10/17/19 22:34 Employee 1 System Architecture Verified 10/14/19 19:18 Employee 1 System Architecture Submitted 9/24/19 20:27 - tamerj1
Community Champion
Anonymous
Ok, that does not match with your initial description. Kindly provide your red markups on below proposal's screenshots.