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 September 15. Request your voucher.

Reply
Mihail_D
New Member

Power BI Count my maximum date

I have the following case, which turned out quite a difficult task. I have a table with employee number and the last date the employee was active. Additionally i have a calendar table. They have a 1:many relationship.

 

employee.png

What i would like to do is create a chart where each employee is counted once for the maximum date where he was active.

 

If i have 3 people where the last actove date was 6/1/2024 on the column chart it will count 3. Each previous date when they were active should be ignored.

It should basically look like this:

Mihail_D_1-1724144706764.png

 

 

 

I tried different things, the last thing i tried after some consultation was the following code:

 

 

Employee max = 
VAR __tbl = 
    FILTER(CALCULATETABLE(
    ADDCOLUMNS(
    SUMMARIZE('Table', 'Table'[PersonId], 'Calendar'[Date]), "distinct", [Employee]), 
    REMOVEFILTERS( 'Calendar'[Date], 'Calendar'[MonthnYear] )), NOT ISBLANK([distinct]))

VAR __last_date_tbl = SELECTCOLUMNS(GROUPBY(__tbl, [PersonId], "zzz", MAXX(CURRENTGROUP(), 'Calendar'[Date])), "dates", [zzz])

RETURN
IF(MAX('Calendar'[Date]) IN __last_date_tbl, 
CALCULATE([Employee]
    , Calendar[Date] = MAX('Calendar'[Date]) --__something
    ))

 

 

It generally works, if i have a single moth selected on the slicer on the page, but if i expand the selection to 2 or 3 months it couns the employee based on the last date he was active for each month. I want it to be counted on the last date for the selected period as a whole. What am i missing that makes the count by month, how can i ignore it?

 

Thank you!

 

1 REPLY 1
lbendlin
Super User
Super User

You need to disconnect the calendar table and use measures.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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