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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Atanas_Atanasov
Helper II
Helper II

Counting Value Based On It's Last Appearence

Dear All,

I have a report which contains person ID.

I'd like to calculate the distinct count of that person ID, based on their last appearence. 

For example I have 1 person who appears only on 01/01/2024 and another person who appears on all other days, but their last appearence is 01/26/2024 (screenshot 1).

I'd like to show a table which has date and the distinct count next to it and it should look like that:

Date:               Count Of Person ID

01/01/2024     1

01/26/2024     1

NOTE: ID2 appears in multiple days, but I am looking for is to show only their last date of appearence in the report. 

I will be deeply grateful if you can help me with that. 

NOTE: This is how my datamodel looks (screenshot 2)

All due respect, 

Atanas

Atanas_Atanasov_0-1723113922298.png

Atanas_Atanasov_1-1723113970860.png

1 ACCEPTED SOLUTION
Atanas_Atanasov
Helper II
Helper II

Ok, I found the solution. 

1. Create table by Person ID, Calendar Date and the distinct count of the person ID. Then removing the filter context from the calendar date and the sorting column in the calendar table:

Atanas_Atanasov_0-1723201238251.png

2. Grouped the table from step 1 by person id, while interating the group to get the last date (MAXX). And then selecting only the column with the latest date:

Atanas_Atanasov_1-1723201374910.png

3. Then if the calendar date = the date found in step 2 return me the distinct count of the person id where the calendar date = last calendar date:

Atanas_Atanasov_2-1723201482007.png

The result is exactly what I was looking for:

Atanas_Atanasov_3-1723201513174.png

Thank you all for your help and suggestions. Hope this might help to you as well!

Have a nice day and great weekend, 

Atanas

View solution in original post

15 REPLIES 15
Atanas_Atanasov
Helper II
Helper II

Ok, I found the solution. 

1. Create table by Person ID, Calendar Date and the distinct count of the person ID. Then removing the filter context from the calendar date and the sorting column in the calendar table:

Atanas_Atanasov_0-1723201238251.png

2. Grouped the table from step 1 by person id, while interating the group to get the last date (MAXX). And then selecting only the column with the latest date:

Atanas_Atanasov_1-1723201374910.png

3. Then if the calendar date = the date found in step 2 return me the distinct count of the person id where the calendar date = last calendar date:

Atanas_Atanasov_2-1723201482007.png

The result is exactly what I was looking for:

Atanas_Atanasov_3-1723201513174.png

Thank you all for your help and suggestions. Hope this might help to you as well!

Have a nice day and great weekend, 

Atanas

Anonymous
Not applicable

Hi @Atanas_Atanasov ,

 

Could you please mark your solution? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Please consider it done. 

Thank you, 

Atanas

ThxAlot
Super User
Super User

Easy enough with a calculated column

ThxAlot_0-1723154215346.png

ThxAlot_1-1723154252999.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


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


)



Thank you for your suggestion, but when added additional months of data, the dates in the column change to the last date in the dataset. I found the solution and will share it below. 

SachinNandanwar
Super User
Super User

Is it possible that there will be multiple entries of a person across the same dates ?

If not then just use this Measure 

MaxDatePresence = CALCULATE(MAX(person[date].[Date]),INDEX(1,DISTINCT(ALL(person)),ORDERBY(person[date].[Date],DESC),PARTITIONBY(person[person])))


Source Data >>
date,personid
1/8/2024,1
2/8/2024,1
5/8/2024,1
8/8/2024,1
11/8/2024,1
3/8/2024,2
4/8/2024,2
10/8/2024,2


o/p >> 

SachinNandanwar_0-1723117986611.png

 



Regards,
Sachin
Check out my Blog

@SachinNandanwar  - Can you please show it as a count of the people? Thank you very much for your help!

@Atanas_Atanasov 
If there is one unique entry of a person across a given date the count would always be one for that given date.



Regards,
Sachin
Check out my Blog

Thank you again, but the result this measure provides is the last date in my dataset (screenshot 1). Except for line 1.

Atanas_Atanasov_0-1723124766477.png

 

I think this is not working due to the fact I have calendar table in my data model (screenshot 2) from my original post, but not sure how to resolve it,

Atanas

 

Could you please share some sample data ?



Regards,
Sachin
Check out my Blog

That's my dataset for January. The only think you have to do is create a calendar and you will have the same datamodel. The relationship is based on calednar.date -> table.MetricDate

MetricDateAppValueRefresh datePersonId
1/1/2024Word9180307/8/2024032d88a7-7ea7-3195-829c-383e976f6cf3
1/2/2024Word9332577/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/3/2024Word4015607/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/4/2024Word377827/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/5/2024Word9341457/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/6/2024Word6254597/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/7/2024Word1665537/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/8/2024Word2100707/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/9/2024Word5247907/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/10/2024Word2189227/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/11/2024Word8677797/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/12/2024Word2819667/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/13/2024Word7199467/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/14/2024Word5183577/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/15/2024Word3558417/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/16/2024Word1559177/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/17/2024Word5772697/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/18/2024Word1546947/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/19/2024Word902367/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/20/2024Word5419387/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/21/2024Word3904357/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/22/2024Word5367007/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/23/2024Word4362657/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/24/2024Word2973947/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/25/2024Word9631077/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3
1/26/2024Word6718287/8/2024031d88a7-7ea7-3195-829c-383e976f6cf3

 

That's all the same person ID?

 

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Have uploaded the pbix file here : https://file.io/JfCJG8VzeyOl


Regards,
Sachin
Check out my Blog
bhanu_gautam
Super User
Super User

@Atanas_Atanasov , First create a calculated column for last appearance

 

LastAppearanceDate =
CALCULATE(
    MAX(PersonAppearances[AppearanceDate]),
    ALLEXCEPT(PersonAppearances, PersonAppearances[PersonID])
)
 
Then create a summary table to show distinct value
SummaryTable =
SUMMARIZE(
    PersonAppearances,
    PersonAppearances[LastAppearanceDate],
    "CountOfPersonID", DISTINCTCOUNT(PersonAppearances[PersonID])
)



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam - Thank you for the suggestion, but is it possible to do it with a measure?

Additinionaly, when I add more months of data the date in the column you suggest automatically changes to the latest in the dataset. While I need this to be calculated for the month in the filter.

Thank you, 

Atanas

Atanas_Atanasov_0-1723117729785.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.