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
JamesLeach
Frequent Visitor

Calculated column or measure? Data from specific row for all rows matching value in another column.

Hello everyone!  

 

I've got a data set similar to this (without the 'UniqueId' column - that's what I'm trying to add).

 

RecordDataValueUniqueId
1UniqueId10011001
1ThomasBoise1001
1Sales2915.351001
1Range-25%1001
2CoryJackson1002
2VincentCharleston1002
2RegionPNW1002
2UniqueId10021002
3UniqueId10011001
3VictorCheyenne1001
3Retired$true1001
4UniqueId10031003
4JustinSalt Lake City1003
5UniqueId10011001
5BrandonDes Moines1001
5PeterSacramento1001
5JoelBaton Rouge1001
5Range44%1001
6JacobHartford1002
6UniqueId10021002
6NotesDiscontinued1002
7Managercc26-4f081004
7DerekAtlanta1004
7UniqueId10041004

 

Each 'Record' will have a 'UniqueId' which I would like to add to each row.  I've done similar things with DAX, using CALCULATE and FILTER, but am having difficulity figuring this one out.   

 

Does anyone have any suggestions? 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

As a calculated column, you could do this:

 

UniqueID = 
VAR __table = FILTER(ALL('Table2'),[Record]=EARLIER([Record]) && [Data]="UniqueId")
RETURN
MAXX(__table,[Value])

As a measure, it would be:

 

mUniqueID = 
VAR __record = MAX([Record])
VAR __table = FILTER(ALL('Table2'),[Record]=__record && [Data]="UniqueId")
RETURN
MAXX(__table,[Value])

Assuming you put it in a visualization with at least Record.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

As a calculated column, you could do this:

 

UniqueID = 
VAR __table = FILTER(ALL('Table2'),[Record]=EARLIER([Record]) && [Data]="UniqueId")
RETURN
MAXX(__table,[Value])

As a measure, it would be:

 

mUniqueID = 
VAR __record = MAX([Record])
VAR __table = FILTER(ALL('Table2'),[Record]=__record && [Data]="UniqueId")
RETURN
MAXX(__table,[Value])

Assuming you put it in a visualization with at least Record.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Great, thank you!  

 

That's exactly what I was looking for.   

 

I really appreaciate your help.

Happy to help!


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.