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
astronauta49
Helper I
Helper I

First value by date

Hello. Can you help me, please ?

I need a table with the same column, with unique (not duplicate) values from IDU column ... filtered by DATE column.

I need the first row (date) of each IDU.

Thanks a lot

 

IDUDATETRIM
12/04/2021AAAA
26/04/2021AAAA
210/04/2021BBB
214/04/2021BBB
318/04/2021CCC
422/04/2021CCC
1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

@astronauta49 

 

Here's the calculated table you want:

[New Table] = // This is a calculated table
// Let the table from your initial post
// be called T (you just substitute the
// name you've got in your model).
var IDUsWithFirstDates =
    ADDCOLUMNS(
        DISTINCT( T[IDU] ),
        "@FirstDate",
            CALCULATE(
                MIN( T[Date] )
            )
    )
var Result =
    CALCULATETABLE(
        T,
        TREATAS(
            IDUsWithFirstDates,
            T[IDU],
            T[DATE]
        )
    )
RETURN
    Result

 

View solution in original post

4 REPLIES 4
daxer-almighty
Solution Sage
Solution Sage

@astronauta49 

 

Here's the calculated table you want:

[New Table] = // This is a calculated table
// Let the table from your initial post
// be called T (you just substitute the
// name you've got in your model).
var IDUsWithFirstDates =
    ADDCOLUMNS(
        DISTINCT( T[IDU] ),
        "@FirstDate",
            CALCULATE(
                MIN( T[Date] )
            )
    )
var Result =
    CALCULATETABLE(
        T,
        TREATAS(
            IDUsWithFirstDates,
            T[IDU],
            T[DATE]
        )
    )
RETURN
    Result

 

amitchandak
Super User
Super User

@astronauta49 , Create a new measure for TRIM  and use min for date if needed

 

new TRIM =
VAR __id = MAX ('Table'[Name] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[Name] = __id )
CALCULATE ( max ('Table'[TRIM] ), VALUES ('Table'[Name] ),'Table'[Name] = __id,'Table'[Date] = __date )

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

thank you so much !!

Sorry, it took me a long time to reply. Thank you very much for your answer. I have not solved my problem yet. I don't understand the code. Do you need to put it in a new measure or column? I'll keep doing tests. Thanks

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.