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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
filarap
Helper III
Helper III

Return Earliest Text Value to all rows of a group

Hi Community,

 

I need help with DAX through PowerPivot (not PowerBI).
I am trying to get the earliest ID of a subset(group) assigned to all rows of that group. The output I am trying to achieve is bellow *Last column - Earliest Unique ID.

 

Any idea how to achieve this without usage of VAR (It does not work for my Excel version)

Case IDRank within GroupUnique ID??? Earliest Unique ID
1111
1221
1331
2144
2254
3166
4177
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@filarap ,

new column  =

minx(filter(Table, [Case ID] =earlier([Case ID])), [Unique ID] )

View solution in original post

Richard_100
Resolver I
Resolver I

Hello

 

This worked for me, although I am not sure about backwards compatibility with Excel versions of DAX.

 

I changed your example table slightly to make Unique ID contain some non-numbers and then focused the solution on the rank rather than minimum Unique ID number, assuming that the rank of a Unique ID might be completely unconnected with the value of the ID itself.

 

Richard_100_0-1643800441010.png

 

This works by filtering the table down to a single row (based on Case ID, referencing the row context of the underlying table via the EARLIER function and the Rank) and a single column, thereby becoming a single cell that DAX can return as a scalar value into the row (tables of one row and column can be treated as both tables and scalars) 

 

=SELECTCOLUMNS(

             FILTER(Table1, ([Case ID]=EARLIER([Case ID])) && [Rank within Group]=1),

             "@Unique", [Unique ID])

 

Hope that helps

 

Regards

Richard

View solution in original post

4 REPLIES 4
filarap
Helper III
Helper III

Hey @Richard_100  and @amitchandak 

 

I managed to achieve it by combining your 2 suggestions:
=minx(filter(Table, [Case ID] =earlier([Case ID]) && [Rank within Group]=1), [Unique ID] )

Unfortunatelly SELECTCOUMN does not work in Excel PowerPivot I have.
The only thin is that I had to format Unique Value as number (last digit get converted to 0) and work around scientific format. But this resolved what I need it for.

Thanks a lot!

Richard_100
Resolver I
Resolver I

Hello

 

This worked for me, although I am not sure about backwards compatibility with Excel versions of DAX.

 

I changed your example table slightly to make Unique ID contain some non-numbers and then focused the solution on the rank rather than minimum Unique ID number, assuming that the rank of a Unique ID might be completely unconnected with the value of the ID itself.

 

Richard_100_0-1643800441010.png

 

This works by filtering the table down to a single row (based on Case ID, referencing the row context of the underlying table via the EARLIER function and the Rank) and a single column, thereby becoming a single cell that DAX can return as a scalar value into the row (tables of one row and column can be treated as both tables and scalars) 

 

=SELECTCOLUMNS(

             FILTER(Table1, ([Case ID]=EARLIER([Case ID])) && [Rank within Group]=1),

             "@Unique", [Unique ID])

 

Hope that helps

 

Regards

Richard

filarap
Helper III
Helper III

Hey @amitchandak 

 

Apologies as i failed to mention, that I am trying to get the Earliest ID using the rank column (Need to assign Unique ID with Rank 1 to all rows of the group).

Also, Case id is formated as text (20char, so numbers transform to scietific formating).

Thanks a lot!!!

amitchandak
Super User
Super User

@filarap ,

new column  =

minx(filter(Table, [Case ID] =earlier([Case ID])), [Unique ID] )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors