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
Anonymous
Not applicable

Calculated table with unique values

I have a calculated table with the following code, that I would like to get unique values from based on the earliest date for "Datum afspraak" (date appointment):

 

CALC NP's (Uniek) = SUMMARIZE('CALC NP''s (Niet uniek)', 
'CALC NP''s (Niet uniek)'[Patiëntnummer],
'CALC NP''s (Niet uniek)'[Geslacht],
'CALC NP''s (Niet uniek)'[Online geboekt], 
'CALC NP''s (Niet uniek)'[Datum afspraak],
'CALC NP''s (Niet uniek)'[Datum boeking],
'CALC NP''s (Niet uniek)'[Gebruiker],
'CALC NP''s (Niet uniek)'[Locatie])

 

The table currently looks like this:

Sohan_0-1639049746455.png

 

I only want the rows to show that contain the earliest "Datum afspraak". There should not be any duplicate values in the column "Patiëntnummer" .Does anyone know how I can achieve this?

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try like

 

Filter(
ADDCOLUMNS( SUMMARIZE('CALC NP''s (Niet uniek)',
'CALC NP''s (Niet uniek)'[Patiëntnummer],
'CALC NP''s (Niet uniek)'[Geslacht],
'CALC NP''s (Niet uniek)'[Online geboekt],
'CALC NP''s (Niet uniek)'[Datum afspraak],
'CALC NP''s (Niet uniek)'[Datum boeking],
'CALC NP''s (Niet uniek)'[Gebruiker],
'CALC NP''s (Niet uniek)'[Locatie]
) , "_Min" , minx(filter('CALC NP''s (Niet uniek)', [Patiëntnummer] =earlier([Patiëntnummer])), 'CALC NP''s (Niet uniek)'[Datum afspraak])
)
_Min = [Datum afspraak] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

try this:-

calc =
FILTER (
    ADDCOLUMNS (
        SUMMARIZE (
            'CALC NP''s (Niet uniek)',
            'CALC NP''s (Niet uniek)'[Patiëntnummer],
            'CALC NP''s (Niet uniek)'[Geslacht],
            'CALC NP''s (Niet uniek)'[Online geboekt],
            'CALC NP''s (Niet uniek)'[Datum afspraak],
            'CALC NP''s (Niet uniek)'[Datum boeking],
            'CALC NP''s (Niet uniek)'[Gebruiker],
            'CALC NP''s (Niet uniek)'[Locatie]
        ),
        "_Min",
            MINX (
                FILTER (
                    'CALC NP''s (Niet uniek)',
                    [Patiëntnummer] = EARLIER ( [Patiëntnummer] )
                ),
                'CALC NP''s (Niet uniek)'[Datum afspraak]
            )
    ),
    [_Min] = [Datum afspraak]
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , Try like

 

Filter(
ADDCOLUMNS( SUMMARIZE('CALC NP''s (Niet uniek)',
'CALC NP''s (Niet uniek)'[Patiëntnummer],
'CALC NP''s (Niet uniek)'[Geslacht],
'CALC NP''s (Niet uniek)'[Online geboekt],
'CALC NP''s (Niet uniek)'[Datum afspraak],
'CALC NP''s (Niet uniek)'[Datum boeking],
'CALC NP''s (Niet uniek)'[Gebruiker],
'CALC NP''s (Niet uniek)'[Locatie]
) , "_Min" , minx(filter('CALC NP''s (Niet uniek)', [Patiëntnummer] =earlier([Patiëntnummer])), 'CALC NP''s (Niet uniek)'[Datum afspraak])
)
_Min = [Datum afspraak] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Anonymous, I think  , was missing, as suggested by @Samarth_18 . Make sure table name before it. and min is column [_Min] 

new table =

Filter(
ADDCOLUMNS( SUMMARIZE('CALC NP''s (Niet uniek)',
'CALC NP''s (Niet uniek)'[Patiëntnummer],
'CALC NP''s (Niet uniek)'[Geslacht],
'CALC NP''s (Niet uniek)'[Online geboekt],
'CALC NP''s (Niet uniek)'[Datum afspraak],
'CALC NP''s (Niet uniek)'[Datum boeking],
'CALC NP''s (Niet uniek)'[Gebruiker],
'CALC NP''s (Niet uniek)'[Locatie]
) , "_Min" , minx(filter('CALC NP''s (Niet uniek)', [Patiëntnummer] =earlier([Patiëntnummer])), 'CALC NP''s (Niet uniek)'[Datum afspraak])
) ,
[_Min] = [Datum afspraak] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks for your response @amitchandak! It says the syntax is incorrect for "_Min = [Datum afspraak]". Any idea what I should change?

 

Sohan_0-1639050979086.png

 

 

Hi @Anonymous ,

There is one comma missing in the code. Below is updated code:-

FILTER (
    ADDCOLUMNS (
        SUMMARIZE (
            'CALC NP''s (Niet uniek)',
            'CALC NP''s (Niet uniek)'[Patiëntnummer],
            'CALC NP''s (Niet uniek)'[Geslacht],
            'CALC NP''s (Niet uniek)'[Online geboekt],
            'CALC NP''s (Niet uniek)'[Datum afspraak],
            'CALC NP''s (Niet uniek)'[Datum boeking],
            'CALC NP''s (Niet uniek)'[Gebruiker],
            'CALC NP''s (Niet uniek)'[Locatie]
        ),
        "_Min",
            MINX (
                FILTER (
                    'CALC NP''s (Niet uniek)',
                    [Patiëntnummer] = EARLIER ( [Patiëntnummer] )
                ),
                'CALC NP''s (Niet uniek)'[Datum afspraak]
            )
    ),
    _Min = [Datum afspraak]
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

@Samarth_18 Thank you for your reply! When I change "_Min =" to "[_Min] =" it works! I now however get the following message: 

Column '' in Table '' contains a duplicate value '457-3773' and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.

 

Any idea how I can get the desired result?

try this:-

calc =
FILTER (
    ADDCOLUMNS (
        SUMMARIZE (
            'CALC NP''s (Niet uniek)',
            'CALC NP''s (Niet uniek)'[Patiëntnummer],
            'CALC NP''s (Niet uniek)'[Geslacht],
            'CALC NP''s (Niet uniek)'[Online geboekt],
            'CALC NP''s (Niet uniek)'[Datum afspraak],
            'CALC NP''s (Niet uniek)'[Datum boeking],
            'CALC NP''s (Niet uniek)'[Gebruiker],
            'CALC NP''s (Niet uniek)'[Locatie]
        ),
        "_Min",
            MINX (
                FILTER (
                    'CALC NP''s (Niet uniek)',
                    [Patiëntnummer] = EARLIER ( [Patiëntnummer] )
                ),
                'CALC NP''s (Niet uniek)'[Datum afspraak]
            )
    ),
    [_Min] = [Datum afspraak]
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

@Samarth_18 Thanks! Please see my previous reply 😊

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.

Top Solution Authors