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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Motomoto
New Member

Get a list with only one individual with the latest next appointment date.

Motomoto_0-1729691354823.png

I need help with creating a new table that will list only people with the latest next appointment date information of each individual.No duplicates should apperar in the new table.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Motomoto , Selva-Salimi, thank you for your prompt reply!

To meet your requirements, follow these steps:

 

Step 1: First, find the maximum HIV-ART Next follow-up date for each Program ID using the MAX function.

Step 2: Then, for the rows with the same maximum HIV-ART Next follow-up date, find the corresponding maximum Date of visit using the MAX function.

Step 3: Use DISTINCT to ensure that the final result contains unique rows.

 

UniqueProgramData = 
DISTINCT(
    FILTER(
        'Table',
        'Table'[HIV-ART Next follow-up date] = 
        CALCULATE(
            MAX('Table'[HIV-ART Next follow-up date]),
            ALLEXCEPT('Table', 'Table'[Program ID])
        ) &&
        'Table'[Date of visit] = 
        CALCULATE(
            MAX('Table'[Date of visit]),
            ALLEXCEPT('Table', 'Table'[Program ID], 'Table'[HIV-ART Next follow-up date])
        )
    )
)

Result for your reference:

vyajiewanmsft_0-1729833593538.png

Best regards,

Joyce

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

5 REPLIES 5
Anonymous
Not applicable

Hi @Motomoto , Selva-Salimi, thank you for your prompt reply!

To meet your requirements, follow these steps:

 

Step 1: First, find the maximum HIV-ART Next follow-up date for each Program ID using the MAX function.

Step 2: Then, for the rows with the same maximum HIV-ART Next follow-up date, find the corresponding maximum Date of visit using the MAX function.

Step 3: Use DISTINCT to ensure that the final result contains unique rows.

 

UniqueProgramData = 
DISTINCT(
    FILTER(
        'Table',
        'Table'[HIV-ART Next follow-up date] = 
        CALCULATE(
            MAX('Table'[HIV-ART Next follow-up date]),
            ALLEXCEPT('Table', 'Table'[Program ID])
        ) &&
        'Table'[Date of visit] = 
        CALCULATE(
            MAX('Table'[Date of visit]),
            ALLEXCEPT('Table', 'Table'[Program ID], 'Table'[HIV-ART Next follow-up date])
        )
    )
)

Result for your reference:

vyajiewanmsft_0-1729833593538.png

Best regards,

Joyce

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

This solved, my problem. thank you all.

Motomoto
New Member

Hello Selva. Thank you very much, the solution is very helpful, but i still have an issue as i still get some duplicates especially if the next follow up dates are within the same month. Thank you very much

@Motomoto ,

 

the next follow up date should just used in max function. if so, would you please share the measure you have written.

Selva-Salimi
Super User
Super User

hi @Motomoto 

 

you can create this table as follows: (go modelling >> new table)

 

summarize( your_table , and write the name of any column you want to appear in this table (note that the values in these columns should be unique per person) , "latest_date" , max (nex_followup_date))

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.