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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DonRitchie
Frequent Visitor

Calculated Table Using SUMMARIZE to return distinct values by max date

Hi all!  Happy New Year!

 

Been banging my head on this all morning.  I am creating a table using the following:

 

EmpTypeTable = SUMMARIZE(Employees,Employees[Employee], Employees[EmployeeType], Employees[Date])

 

An Employee many have multiple EmployeeType's.  I want to return the EmployeeType with the most recent date.


I have this: 

 

Employee EmployeeType Date
APT1/1/2024
BPT12/1/2023
BFT12/25/2023
CFT11/28/2023
CPT

12/15/2023

 

I want this:

 

Employee EmployeeType Date
APT1/1/2024
BFT12/25/2023
CPT12/15/2023

 

I have tried GROUPBY, and various FILTER commands, and SUMMARIZETABLE.  I can't figure it out.  I get errors about scalars into scalars.  I could even live with a calculated column that kept the original table and ADDCOLUMN'd the EmployeeType with the max date.

2 ACCEPTED SOLUTIONS
ThxAlot
Super User
Super User

ThxAlot_1-1704225163890.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

Anonymous
Not applicable

Hi @DonRitchie 

 

@ThxAlot Good share!

 

For your question, here I give you the other method:

 

Here is the data you provided

 

“Employees”

vnuocmsft_0-1704266632602.png

 

First, create a measure to calculate the “max_date”

vnuocmsft_1-1704266655886.png

 

max_date = 
CALCULATE(MAX('Employees'[Date]), 
FILTER(ALL('Employees'), 'Employees'[Employee ] = MAX('Employees'[Employee ])))

 

 

Then, create a new table

vnuocmsft_2-1704266752718.png

 

result_employees = 
SELECTCOLUMNS(FILTER(ALL('Employees'), 
'Employees'[Date] = [max_date]), 
"employee", 'Employees'[Employee ], "employtype", 'Employees'[EmployeeType ], "date", 'Employees'[Date])

 

 

Here is the result

vnuocmsft_3-1704266827755.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @DonRitchie 

 

@ThxAlot Good share!

 

For your question, here I give you the other method:

 

Here is the data you provided

 

“Employees”

vnuocmsft_0-1704266632602.png

 

First, create a measure to calculate the “max_date”

vnuocmsft_1-1704266655886.png

 

max_date = 
CALCULATE(MAX('Employees'[Date]), 
FILTER(ALL('Employees'), 'Employees'[Employee ] = MAX('Employees'[Employee ])))

 

 

Then, create a new table

vnuocmsft_2-1704266752718.png

 

result_employees = 
SELECTCOLUMNS(FILTER(ALL('Employees'), 
'Employees'[Date] = [max_date]), 
"employee", 'Employees'[Employee ], "employtype", 'Employees'[EmployeeType ], "date", 'Employees'[Date])

 

 

Here is the result

vnuocmsft_3-1704266827755.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

This works as well, in the situation where I would want a comparison table.  Thank you!

ThxAlot
Super User
Super User

ThxAlot_1-1704225163890.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Perfect.  Exactly what I was looking for, and the process is easily understandable for when I need to do similar calculations (all the time).  Although, I had to add DEFAULT, between ORDERBY and PARTITIONBY. 

Thank you!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.